Skip to content

Get Object's Parent Paths

Get hierarchy path from the specified object to the root object.

Request

HTTP Request

GET /node/api/objects/:id/paths

Permissions

objectPermissions

Path parameters

Parameter Type Description
id String ID of the object which paths to retrieve.

Query parameters

Parameter Type Description
fields String Comma-separated list of parent objects' fields to return.

Request body

The request body is empty.

Response

Response contains two lists – paths and objects.

paths contains IDs of every parent object (including the root object) and the ID of the requested object itself. The first element in the list is the requested object, the last is the root object.

objects list contains information about each object in the path. You can select returned fields with the fields query parameter. You can see the list of all possible fields in the Object model article.

By default, each objects includes the following fields:

Field Type Description
id String Object's ID.
name String Object's name.
class_id String The ID of an object class.
child_ids Array<String> An array of object's child objects IDs.
child_link_ids Array<String> An array of object's child links IDs.
child_ref_ids Array<String> An array of object's child references IDs.
parent_id Array<String> The IDs of an object's parents.
geoposition Array<Float> Object's position on a map. It's specified as an array of two float numbers, where the first number is longitude, the second one is latitude.
geopositionRadius Integer The radius of an object's area displayed on a map.
state_id String The ID of an object state.
last_state_update Integer A timestamp when object's state was last updated.

Examples

Request

login=<...>
password=<...>
saymon_hostname=<...>
object_id=<...>
url=https://$saymon_hostname/node/api/objects/$object_id/paths?fields=id,name

curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let path = "/node/api/objects/" + objectId + "/paths?fields=id,name";
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Authorization", auth);

let requestOptions = {
    method: "GET",
    headers: headers
};

fetch(saymonHostname + path, requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log("error", error));
const http = require("http");

let login = <...>
let password = <...>
let saymonHostname = <...>
let objectId = <...>
let path = "/node/api/objects/" + objectId + "/paths?fields=id,name";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "GET",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth
    },
    "path": path
};

let req = http.request(options, function (res) {
    let chunks = [];

    res.on("data", function (chunk) {
        chunks.push(chunk);
    });

    res.on("end", function (chunk) {
        let body = Buffer.concat(chunks);
        console.log(body.toString());
    });

    res.on("error", function (error) {
        console.error(error);
    });
});

req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
object_id = <...>
url = "https://" + saymon_hostname + "/node/api/objects/" + object_id + "/paths?fields=id,name"

response = requests.request("GET", url, auth=(login, password))
print(response.text)

Response

{
    "paths": [
        [
            "62bed6392b23924839fa4eb4",
            "62bed6392b23924839fa4e93",
            1
        ]
    ],
    "objects": [
        {
            "name": "File System",
            "id": "62bed6392b23924839fa4eb4"
        },
        {
            "name": "Saymon root",
            "id": 1
        },
        {
            "name": "Host (172.20.0.7)",
            "id": "62bed6392b23924839fa4e93"
        }
    ]
}