Update Object

PATCH /node/api/objects/:id

Updates object's fields specified in a request body.
Permissions: objectPermissions & (modify-objects | manage-objects).

Request parameters

Path parameters

Parameter
Type
Description
id
String
required
The ID of an object to be updated.

Body parameters

See the Object model.

Response description

See the Object model.

Examples

Request examples

The code examples below show how to change an object's name using the described method:
Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
object_id=<...>
5
url=https://$saymon_hostname/node/api/objects/$object_id
6
7
curl -X PATCH $url -u $login:$password \
8
-H "Content-Type: application/json" \
9
-d @- <<EOF
10
{
11
"name": "Updated Object"
12
}
13
EOF
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let objectId = <...>
5
let path = "/node/api/objects/" + objectId;
6
let auth = "Basic " + btoa(login + ":" + password);
7
8
let headers = new Headers();
9
headers.append("Content-Type", "application/json");
10
headers.append("Authorization", auth);
11
12
let data = JSON.stringify({
13
"name": "Updated Object"
14
});
15
16
let requestOptions = {
17
method: "PATCH",
18
headers: headers,
19
body: data
20
};
21
22
fetch(saymonHostname + path, requestOptions)
23
.then(response => response.text())
24
.then(result => console.log(result))
25
.catch(error => console.log("error", error));
Copied!
1
const http = require("http");
2
3
let login = <...>
4
let password = <...>
5
let saymonHostname = <...>
6
let objectId = <...>
7
let path = "/node/api/objects/" + objectId;
8
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
9
10
let options = {
11
"method": "PATCH",
12
"hostname": saymonHostname,
13
"headers": {
14
"Authorization": auth,
15
"Content-Type": "application/json"
16
},
17
"path": path
18
};
19
20
let req = http.request(options, function (res) {
21
let chunks = [];
22
23
res.on("data", function (chunk) {
24
chunks.push(chunk);
25
});
26
27
res.on("end", function (chunk) {
28
let body = Buffer.concat(chunks);
29
console.log(body.toString());
30
});
31
32
res.on("error", function (error) {
33
console.error(error);
34
});
35
});
36
37
let data = JSON.stringify({
38
name: "Updated Object",
39
});
40
41
req.write(data);
42
req.end();
Copied!
1
import requests
2
3
login = <...>
4
password = <...>
5
saymon_hostname = <...>
6
object_id = <...>
7
url = "https://" + saymon_hostname + "/node/api/objects/" + object_id
8
9
body = {
10
"name": "Updated Object"
11
}
12
13
response = requests.request("PATCH", url, auth=(login, password), json=body)
14
print(response.text)
Copied!

Response example

1
{
2
"id": "5e79b74d6ec5ea28e5105c58",
3
"name": "Updated Object",
4
"owner_id": "5e21b752308c3c66d64e072c",
5
"object_groups": [],
6
"geoposition": [],
7
"child_ref_ids": [],
8
"child_link_ids": [],
9
"child_ids": [],
10
"parent_id": "1",
11
"weight": 1,
12
"tags": [],
13
"last_state_update": 1585035085802,
14
"updated": 1585035624177,
15
"created": 1585035085802,
16
"state_id": 1,
17
"class_id": 13,
18
"_stateConditionRefs": [],
19
"operations": [],
20
"properties": [],
21
"client_data": "{...}"
22
}
Copied!
Last modified 1yr ago