Calling external APIs Last updated: 06. Mar 2026

Examples for API functions calling external WEB APIs (JSON) with POST and GET.

IMPORTANT: These functions are only available from the #/API folder.

httpGet(url, [headers])

Below an example API endpoint #/API/test.js calling an API endpoint.

export default () => {
    /* Basic authentication */
    let headers = {
        "Authorization" : "BASIC " + docly.base64(login + ":" + password)
    };
    
    /* Call server */
    let result = docly.httpGet("https://docly.net/API/Folder/Dir?id=1", data, headers);
    
    /* Output result */
    return JSON.stringify(result);
}

httpPost(url, data, [headers])

Posts data serialized as JSON to url. (.NET PostAsJsonAsync)

/* Build query string */
let data = {
    id : 1
};

/* Basic authentication */
let headers = {
    "Authorization" : "BASIC " + docly.base64(login + ":" + password)
};

/* Call server */
let result = docly.httpPost("https://docly.net/API/Folder/Dir", data, headers);

/* ... */

HttpFormPost

Same as HttpPost only posting as a form. Old school but used many places.

Handle exceptions

If an exception occours you can check the "Error"

/* Call server */
let result = docly.httpPost("https://docly.net/API/Folder/Dir", data, headers);

/* Check for error */
if(result.DoclyError) throw new Error(result.DoclyError);


/* ... */