Chilkat Online Tools

Node.js / easybill REST API / Download a specific file for a single version of a given document

Back to Collection Items

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}


function chilkatExample() {

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    var http = new chilkat.Http();
    var success;

    http.SetRequestHeader("Authorization","{{apiKey}}");
    http.SetRequestHeader("Accept","application/pdf");

    var sbResponseBody = new chilkat.StringBuilder();
    success = http.QuickGetSb("https://api.easybill.de/rest/v1/documents/:id/versions/:versionId/items/:versionItemId/download",sbResponseBody);
    if (success == false) {
        console.log(http.LastErrorText);
        return;
    }

    var xmlResponse = new chilkat.Xml();
    xmlResponse.LoadSb(sbResponseBody,true);
    console.log(xmlResponse.GetXml());

    // Sample XML response:
    // (Sample code for parsing the XML response is shown below)

    // <?xml version="1.0" encoding="UTF-8"?>
    // <element>(string)</element>

    // Sample code for parsing the XML response...
    // Use this online tool to generate parsing code from sample XML: Generate XML Parsing Code

    var element = xmlResponse.Content;

}

chilkatExample();

Curl Command

curl -X GET
	-H "Authorization: {{apiKey}}"
	-H "Accept: application/pdf"
https://api.easybill.de/rest/v1/documents/:id/versions/:versionId/items/:versionItemId/download

Postman Collection Item JSON

{
  "name": "Download a specific file for a single version of a given document",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/pdf"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/documents/:id/versions/:versionId/items/:versionItemId/download",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "documents",
        ":id",
        "versions",
        ":versionId",
        "items",
        ":versionItemId",
        "download"
      ],
      "variable": [
        {
          "key": "id",
          "value": "<long>",
          "description": "(Required) ID of document"
        },
        {
          "key": "versionId",
          "value": "<long>",
          "description": "(Required) ID of document version"
        },
        {
          "key": "versionItemId",
          "value": "<long>",
          "description": "(Required) ID of document version item"
        }
      ]
    }
  },
  "response": [
    {
      "name": "Successful operation",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/pdf"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/documents/:id/versions/:versionId/items/:versionItemId/download",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "documents",
            ":id",
            "versions",
            ":versionId",
            "items",
            ":versionItemId",
            "download"
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "versionId"
            },
            {
              "key": "versionItemId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "xml",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/xml"
        }
      ],
      "cookie": [
      ],
      "body": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<element>(string)</element>"
    },
    {
      "name": "Document Version does not exist",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/documents/:id/versions/:versionId/items/:versionItemId/download",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "documents",
            ":id",
            "versions",
            ":versionId",
            "items",
            ":versionItemId",
            "download"
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "versionId"
            },
            {
              "key": "versionItemId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Too Many Requests",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/documents/:id/versions/:versionId/items/:versionItemId/download",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "documents",
            ":id",
            "versions",
            ":versionId",
            "items",
            ":versionItemId",
            "download"
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "versionId"
            },
            {
              "key": "versionItemId"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}