Skip to content

Add Link's Document

Adds a new document for a link. Returns the ID of the created document.

Request

HTTP Request

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

Permissions

upload-documents | create-documents | manage-documents | manage-links

Path parameters

Parameter Type Description
id String
required
The ID of a link for which a document should 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 Bus (Computing)",
  "type_id": 6,
  "value": "https://en.wikipedia.org/wiki/Bus_(computing)"
}

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>
link_id=<your_link_id>
url=https://$saymon_hostname/node/api/links/$link_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 link_id = <your_link_id>
let url = "https://" + saymon_hostname + "/node/api/links/" +
    link_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>
link_id = <your_link_id>
url = "https://" + saymon_hostname + "/node/api/links/" + \
    link_id + "/docs"

with open("/path/to/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>
link_id=<your_link_id>
url=https://$saymon_hostname/node/api/links/$link_id/docs

curl -F "file=@/path/to/Bus_(computing).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 link_id = <your_link_id>
let url = "https://" + saymon_hostname + "/node/api/links/" +
    link_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/Bus_(computing).pdf"),
        filetype: "pdf",
        filename: "Bus_(computing).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>
link_id = <your_link_id>
url = "https://" + saymon_hostname + "/node/api/links/" + \
    link_id + "/docs"

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

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