Skip to content

Add Object's Document

Add a new document for an object with the specified ID.

Request

HTTP Request

POST /node/api/objects/:id/docs

Permissions

upload-documents | create-documents | manage-documents | manage-objects

Path parameters

Parameter Type Description
id

string

required

The ID or discovery ID of the object for which a document must be added.

Request body

The request body is empty.

Response

Work in Progress

This topic is a work in progress and may be incomplete.

Examples

Given below is an example of a JSON-encoded request body representing a link to a document:

{
    "name": "About CPU",
    "type_id": 6,
    "value": "https://en.wikipedia.org/wiki/Central_processing_unit"
}

Provided the content is saved in a file named body.json, a request can be done like this:

login=<your_login>
password=<your_password>
saymon_hostname=<your_saymon_hostname>
object_id=<your_object_id>
url=https://$saymon_hostname/node/api/objects/$object_id/docs

curl -X POST $url -u $login:$password \
    -H "Content-Type: application/json" \
    --data @/path/to/body.json
const request = require("request");
const fs = require("fs");

let login = <your_login>
let password = <your_password>
let saymon_hostname = <your_saymon_hostname>
let object_id = <your_object_id>
let url = "https://" + saymon_hostname + "/node/api/objects/" +
    object_id + "/docs";

let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
let body = JSON.parse(fs.readFileSync("/path/to/body.json"));

let options = {
    method: "POST",
    url: url,
    headers: {
        Authorization: auth
    },
    json : body
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);
});
import requests
import json

login = <your_login>
password = <your_password>
saymon_hostname = <your_saymon_hostname>
object_id = <your_object_id>
url = "https://" + saymon_hostname + "/node/api/objects/" + \
    object_id + "/docs";

with open("body.json", "r") as f:
    body = json.load(f)

response = requests.request("POST", url, json=body, auth=(login, password))
print(response.text)

Uploading a new document

login=<your_login>
password=<your_password>
saymon_hostname=<your_saymon_hostname>
object_id=<your_object_id>
url=https://$saymon_hostname/node/api/objects/$object_id/docs

curl -F "file=@/path/to/cpu.pdf;type=application/pdf" $url \
    -u $login:$password
const request = require('request');
const fs = require('fs');

let login = <your_login>
let password = <your_password>
let saymon_hostname = <your_saymon_hostname>
let object_id = <your_object_id>
let url = "https://" + saymon_hostname + "/node/api/objects/" +
    object_id + "/docs";

let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    method: "POST",
    url: url,
    headers: {
        Authorization: auth
    },
    formData: {
        file: fs.createReadStream("path/to/cpu.pdf"),
        filetype: "pdf",
        filename: "cpu.pdf"
    }
};

request(options, function (error, response, body) {
    if (error) throw new Error(error);
    console.log(body);
});
import requests
import json

login = <your_login>
password = <your_password>
saymon_hostname = <your_saymon_hostname>
object_id = <your_object_id>
url = "https://" + saymon_hostname + "/node/api/objects/" + \
    object_id + "/docs";

files = {
    "file": (
        "cpu.pdf",
        open("/path/to/cpu.pdf", "rb"),
        "application/pdf"
    )
}

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