Add Object's Document [*]

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

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

Permissions: upload-documents | create-documents | manage-documents | manage-objects.

Request parameters

Path parameters

Parameter

Type

Description

id

string

required

The ID of a document for which a document should be added.

Response description

...

Examples

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

body.json
{
"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:

Bash
NodeJS
Python
Bash
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
NodeJS
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);
});
Python
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

Bash
NodeJS
Python
Bash
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
NodeJS
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);
});
Python
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)