Create Dictionary [?]

POST /node/api/dictionaries

Creates a new dictionary.
Permissions: [?]

Request parameters

Body parameters

...

Response description

...

Examples

Request examples

Bash
JavaScript
NodeJS
Python
1
login=<...>
2
password=<...>
3
saymon_hostname=<...>
4
url=https://$saymon_hostname/node/api/dictionaries
5
6
curl -X POST $url -u $login:$password \
7
-H "Content-Type: application/json" \
8
-d @- <<EOF
9
{
10
"name": "Door state",
11
"content": {
12
"0": "Closed",
13
"1": "Opened"
14
}
15
}
16
EOF
Copied!
1
let login = <...>
2
let password = <...>
3
let saymonHostname = <...>
4
let path = "/node/api/dictionaries";
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": "Door state",
13
"content": {
14
"0": "Closed",
15
"1": "Opened"
16
}
17
});
18
19
let requestOptions = {
20
method: "POST",
21
headers: headers,
22
body: data
23
};
24
25
fetch(saymonHostname + path, requestOptions)
26
.then(response => response.text())
27
.then(result => console.log(result))
28
.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/dictionaries";
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": "Door state",
38
"content": {
39
"0": "Closed",
40
"1": "Opened"
41
}
42
});
43
44
req.write(data);
45
req.end();
Copied!
1
import requests
2
3
login = <...>
4
password = <...>
5
saymon_hostname = <...>
6
url = "https://" + saymon_hostname + "/node/api/dictionaries"
7
8
body = {
9
"name": "Door state",
10
"content": {
11
"0": "Closed",
12
"1": "Opened"
13
}
14
}
15
16
response = requests.request("POST", url, json=body, auth=(login, password))
17
print(response.text)
Copied!

Response example

1
{
2
"name": "Door state",
3
"content": "{\"0\":\"Closed\",\"1\":\"Opened\"}",
4
"id": "5e9eb45df0187a38bf7ac390"
5
}
Copied!