Update features
Required capabilities:
geospatialAcl:READgeospatialAcl:WRITE
Update features. This is a replace operation, i.e., all feature properties have to be sent in the request body even if their values do not change.
const featuresToDelete = [{ externalId: 'measurement_point_765' }, { externalId: 'measurement_point_765' }];
await client.geospatial.feature.delete('ocean_temperature', featuresToDelete);
const featuresToUpdate = [
{ externalId: 'measurement_point_765', temperature: 5.65, location: { wkt: 'POINT(60.547602 -5.423433)' } },
{ externalId: 'measurement_point_863', temperature: 5.03, location: { wkt: 'POINT(60.585858 -6.474416)' } }
];
const updatedFeatures = await client.geospatial.feature.update('ocean_temperature', featuresToUpdate);curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"externalId": "measurement_point_765",
"temperature": 5.65,
"location": {
"wkt": "POINT(60.547602 -5.423433)"
}
},
{
"externalId": "measurement_point_863",
"temperature": 5.03,
"location": {
"wkt": "POINT(60.585858 -6.474416)"
}
}
]
}
'import requests
url = "https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update"
payload = { "items": [
{
"externalId": "measurement_point_765",
"temperature": 5.65,
"location": { "wkt": "POINT(60.547602 -5.423433)" }
},
{
"externalId": "measurement_point_863",
"temperature": 5.03,
"location": { "wkt": "POINT(60.585858 -6.474416)" }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'externalId' => 'measurement_point_765',
'temperature' => 5.65,
'location' => [
'wkt' => 'POINT(60.547602 -5.423433)'
]
],
[
'externalId' => 'measurement_point_863',
'temperature' => 5.03,
'location' => [
'wkt' => 'POINT(60.585858 -6.474416)'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"externalId\": \"measurement_point_765\",\n \"temperature\": 5.65,\n \"location\": {\n \"wkt\": \"POINT(60.547602 -5.423433)\"\n }\n },\n {\n \"externalId\": \"measurement_point_863\",\n \"temperature\": 5.03,\n \"location\": {\n \"wkt\": \"POINT(60.585858 -6.474416)\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"externalId\": \"measurement_point_765\",\n \"temperature\": 5.65,\n \"location\": {\n \"wkt\": \"POINT(60.547602 -5.423433)\"\n }\n },\n {\n \"externalId\": \"measurement_point_863\",\n \"temperature\": 5.03,\n \"location\": {\n \"wkt\": \"POINT(60.585858 -6.474416)\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"externalId\": \"measurement_point_765\",\n \"temperature\": 5.65,\n \"location\": {\n \"wkt\": \"POINT(60.547602 -5.423433)\"\n }\n },\n {\n \"externalId\": \"measurement_point_863\",\n \"temperature\": 5.03,\n \"location\": {\n \"wkt\": \"POINT(60.585858 -6.474416)\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"externalId": "measurement_point_765",
"temperature": 5.65,
"location": {
"wkt": "POINT(60.547602 -5.423433)"
},
"createdTime": 1629784673505,
"lastUpdatedTime": 1629784673505
},
{
"externalId": "measurement_point_863",
"temperature": 5.03,
"location": {
"wkt": "POINT(60.585858 -6.474416)"
},
"createdTime": 1629784673505,
"lastUpdatedTime": 1629784673505
}
]
}{
"error": {
"code": 401,
"message": "Could not authenticate.",
"missing": [
{}
],
"duplicated": [
{}
],
"invalid": [
{}
],
"dependencies": [
{}
]
}
}Authorizations
Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
Scopes
Path Parameters
Body
List of features to update.
Optional parameter indicating if input geometry properties should be transformed into the respective Coordinate Reference Systems defined in the feature type specification. If the parameter is true, then input geometries will be transformed when the input and output Coordinate Reference Systems differ. When it is false, then requests with geometries in Coordinate Reference System different from the ones defined in the feature type will result in bad request response code. Transformations apply to property geometries in case of create and update feature, as well as to geometries in spatial filters in search endpoints.
true
const featuresToDelete = [{ externalId: 'measurement_point_765' }, { externalId: 'measurement_point_765' }];
await client.geospatial.feature.delete('ocean_temperature', featuresToDelete);
const featuresToUpdate = [
{ externalId: 'measurement_point_765', temperature: 5.65, location: { wkt: 'POINT(60.547602 -5.423433)' } },
{ externalId: 'measurement_point_863', temperature: 5.03, location: { wkt: 'POINT(60.585858 -6.474416)' } }
];
const updatedFeatures = await client.geospatial.feature.update('ocean_temperature', featuresToUpdate);curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"externalId": "measurement_point_765",
"temperature": 5.65,
"location": {
"wkt": "POINT(60.547602 -5.423433)"
}
},
{
"externalId": "measurement_point_863",
"temperature": 5.03,
"location": {
"wkt": "POINT(60.585858 -6.474416)"
}
}
]
}
'import requests
url = "https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update"
payload = { "items": [
{
"externalId": "measurement_point_765",
"temperature": 5.65,
"location": { "wkt": "POINT(60.547602 -5.423433)" }
},
{
"externalId": "measurement_point_863",
"temperature": 5.03,
"location": { "wkt": "POINT(60.585858 -6.474416)" }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'externalId' => 'measurement_point_765',
'temperature' => 5.65,
'location' => [
'wkt' => 'POINT(60.547602 -5.423433)'
]
],
[
'externalId' => 'measurement_point_863',
'temperature' => 5.03,
'location' => [
'wkt' => 'POINT(60.585858 -6.474416)'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"externalId\": \"measurement_point_765\",\n \"temperature\": 5.65,\n \"location\": {\n \"wkt\": \"POINT(60.547602 -5.423433)\"\n }\n },\n {\n \"externalId\": \"measurement_point_863\",\n \"temperature\": 5.03,\n \"location\": {\n \"wkt\": \"POINT(60.585858 -6.474416)\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"externalId\": \"measurement_point_765\",\n \"temperature\": 5.65,\n \"location\": {\n \"wkt\": \"POINT(60.547602 -5.423433)\"\n }\n },\n {\n \"externalId\": \"measurement_point_863\",\n \"temperature\": 5.03,\n \"location\": {\n \"wkt\": \"POINT(60.585858 -6.474416)\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/geospatial/featuretypes/{featureTypeExternalId}/features/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"externalId\": \"measurement_point_765\",\n \"temperature\": 5.65,\n \"location\": {\n \"wkt\": \"POINT(60.547602 -5.423433)\"\n }\n },\n {\n \"externalId\": \"measurement_point_863\",\n \"temperature\": 5.03,\n \"location\": {\n \"wkt\": \"POINT(60.585858 -6.474416)\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"externalId": "measurement_point_765",
"temperature": 5.65,
"location": {
"wkt": "POINT(60.547602 -5.423433)"
},
"createdTime": 1629784673505,
"lastUpdatedTime": 1629784673505
},
{
"externalId": "measurement_point_863",
"temperature": 5.03,
"location": {
"wkt": "POINT(60.585858 -6.474416)"
},
"createdTime": 1629784673505,
"lastUpdatedTime": 1629784673505
}
]
}{
"error": {
"code": 401,
"message": "Could not authenticate.",
"missing": [
{}
],
"duplicated": [
{}
],
"invalid": [
{}
],
"dependencies": [
{}
]
}
}