Generate Property Inventory Report

Generates a property inventory report for objects matching specified criteria and returns it as an Excel spreadsheet.

Request

HTTP Request

POST /node/api/reports/prop-inventory/excel

Permissions

objectPermissions

Path parameters

No parameters required.

Body parameters

This request uses the same search criteria as the Search Objects request.

Request body

The request body contains the search criteria or the objects that would be included in the report.

{
    "name": {
        "$regex": "^test$",
        "$options": "i"
    },
    "class_id": 24
}

Response

Returns an Excel spreadsheet that contains property inventory report for objects that matched the search criteria.

Property inventory has the following structure:

Object Created property_1 <...> property_N

<Object Name 1>

DD.MM.YYYY, HH:MM:SS

value

<...>

value

<Object Name 2>

DD.MM.YYYY, HH:MM:SS

value

<...>

value

The list of properties includes all properties from every matched object. If an object doesn’t have the property, the value cell would be empty.

Example

Request

As this request returns the XLSX file, you should output it directly to the output file to avoid corrupting it.

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/reports/prop-inventory/excel

curl -X POST $url +
    -H "Content-Type: application/json" +
-o report.xlsx +
    -d @- <<EOF
{
    "name": {
        "$regex": "{caret}CPU$",
        "$options": "i"
    },
    "class_id": 4,
    "parent_id": "62d7e58056d203149a08001b"
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/reports/prop-inventory/excel";

let headers = new Headers();
headers.append("Content-Type", "application/json");

let data = JSON.stringify({
    "name": {
        "$regex": "^CPU$",
        "$options": "i"
    },
    "class_id": 4,
    "parent_id": "62d7e58056d203149a08001b"
});

let requestOptions = {
    method: "POST",
    headers: headers,
    body: data
};

fetch(saymonHostname + path, requestOptions)
    .then(response => response.blob())
    .then(blob => {
    var file = window.URL.createObjectURL(blob);
    window.location.assign(file);
  })
    .catch(error => console.log("error", error));
const http = require("http");
const fs = require("fs");

let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/reports/prop-inventory/excel";

let options = {
    "method": "POST",
    "hostname": saymonHostname,
    "headers": {
      "Content-Type": "application/json"
    },
    "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);

  fs.writeFile('report.xlsx', body.toString(), function (err) {
      if (err) return console.log(err);
      console.log('Saved report.xlsx');
    });
});

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

let data = JSON.stringify({
    "name": {
        "$regex": "{caret}CPU$",
        "$options": "i"
    },
    "class_id": 4,
    "parent_id": "62d7e58056d203149a08001b"
});

req.write(data);
req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
url = "http://" + saymon_hostname + "/node/api/reports/prop-inventory/excel"

json = {
    "name": {
        "$regex": "^CPU$",
        "$options": "i"
    },
    "class_id": 4,
    "parent_id": "62d7e58056d203149a08001b"
}

response = requests.request("POST", url, json=json, auth=(login, password))
f = open("report.xlsx", "w")
f.write(response.text)
f.close()

Response

The response contains a binary representation of the Excel table with the inventory report:

Object Created property1 property2

CPU

21.12.2016, 16:41:50

value1

value 3

CPU

11.04.2018, 17:10:38

value 4

CPU

23.07.2018, 13:46:45

value2

See Also