Add Link's Document [*]

POST /node/api/links/:id/docs

Adds a new document for a link. Returns the ID of the created document.
Permissions: upload-documents | create-documents | manage-documents | manage-links.

Request parameters

Path parameters

Parameter
Type
Description
id
string
required
The ID of a link 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
1
{
2
"name": "About Bus (Computing)",
3
"type_id": 6,
4
"value": "https://en.wikipedia.org/wiki/Bus_(computing)"
5
}
Copied!
Provided the content is saved in a file named body.json, a request can be done like this:
Bash
NodeJS
Python
1
login=<your_login>
2
password=<your_password>
3
saymon_hostname=<your_saymon_hostname>
4
link_id=<your_link_id>
5
url=https://$saymon_hostname/node/api/links/$link_id/docs
6
7
curl -X POST $url -u $login:$password \
8
-H "Content-Type: application/json" \
9
--data @/path/to/body.json
Copied!
1
const request = require("request");
2
const fs = require("fs");
3
4
let login = <your_login>
5
let password = <your_password>
6
let saymon_hostname = <your_saymon_hostname>
7
let link_id = <your_link_id>
8
let url = "https://" + saymon_hostname + "/node/api/links/" +
9
link_id + "/docs";
10
11
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
12
let body = JSON.parse(fs.readFileSync("/path/to/body.json"));
13
14
let options = {
15
method: "POST",
16
url: url,
17
headers: {
18
Authorization: auth
19
},
20
json : body
21
};
22
23
request(options, function (error, response, body) {
24
if (error) throw new Error(error);
25
});
Copied!
1
import requests
2
import json
3
4
login = <your_login>
5
password = <your_password>
6
saymon_hostname = <your_saymon_hostname>
7
link_id = <your_link_id>
8
url = "https://" + saymon_hostname + "/node/api/links/" + \
9
link_id + "/docs"
10
11
with open("/path/to/body.json", "r") as f:
12
body = json.load(f)
13
14
response = requests.request("POST", url, json=body, auth=(login, password))
15
print(response.text)
Copied!

Uploading a new document

Bash
NodeJS
Python
1
login=<your_login>
2
password=<your_password>
3
saymon_hostname=<your_saymon_hostname>
4
link_id=<your_link_id>
5
url=https://$saymon_hostname/node/api/links/$link_id/docs
6
7
curl -F "[email protected]/path/to/Bus_(computing).pdf;type=application/pdf" $url \
8
-u $login:$password
Copied!
1
const request = require("request");
2
const fs = require("fs");
3
4
let login = <your_login>
5
let password = <your_password>
6
let saymon_hostname = <your_saymon_hostname>
7
let link_id = <your_link_id>
8
let url = "https://" + saymon_hostname + "/node/api/links/" +
9
link_id + "/docs";
10
11
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");
12
13
let options = {
14
method: "POST",
15
url: url,
16
headers: {
17
Authorization: auth
18
},
19
formData: {
20
file: fs.createReadStream("/path/to/Bus_(computing).pdf"),
21
filetype: "pdf",
22
filename: "Bus_(computing).pdf"
23
}
24
};
25
26
request(options, function (error, response, body) {
27
if (error) throw new Error(error);
28
console.log(body);
29
});
Copied!
1
import requests
2
import json
3
4
login = <your_login>
5
password = <your_password>
6
saymon_hostname = <your_saymon_hostname>
7
link_id = <your_link_id>
8
url = "https://" + saymon_hostname + "/node/api/links/" + \
9
link_id + "/docs"
10
11
files = {
12
"file": (
13
"Bus_(computing).pdf",
14
open("/path/to/resources/Bus_(computing).pdf", "rb"),
15
"application/pdf"
16
)
17
}
18
19
response = requests.request("POST", url, files=files, auth=(login, password))
20
print(response.text)
Copied!
Last modified 1yr ago