Create Object

POST /node/api/objects

Creates a new object with data passed in a request body.
Permissions: create-objects | manage-objects.

Request parameters

Body parameters

See the Object model.

Response description

See the Object model.

Examples

Request examples

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

Response example

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