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;
var req = new chilkat.HttpRequest();
req.HttpVerb = "POST";
req.Path = "/rest/v1/attachments";
req.ContentType = "multipart/form-data";
req.AddParam("file","<string>");
req.AddHeader("Authorization","{{apiKey}}");
req.AddHeader("Accept","application/json");
// resp: HttpResponse
var resp = http.SynchronousRequest("api.easybill.de",443,true,req);
if (http.LastMethodSuccess == false) {
console.log(http.LastErrorText);
return;
}
var sbResponseBody = new chilkat.StringBuilder();
resp.GetBodySb(sbResponseBody);
var jResp = new chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;
console.log("Response Body:");
console.log(jResp.Emit());
var respStatusCode = resp.StatusCode;
console.log("Response Status Code = " + respStatusCode);
if (respStatusCode >= 400) {
console.log("Response Header:");
console.log(resp.Header);
console.log("Failed.");
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "created_at": "<date>",
// "customer_id": null,
// "document_id": null,
// "file_name": "<string>",
// "id": "<long>",
// "project_id": null,
// "size": "<integer>"
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
var created_at = jResp.StringOf("created_at");
var customer_id = jResp.StringOf("customer_id");
var document_id = jResp.StringOf("document_id");
var file_name = jResp.StringOf("file_name");
var id = jResp.StringOf("id");
var project_id = jResp.StringOf("project_id");
var size = jResp.StringOf("size");
}
chilkatExample();
Curl Command
curl -X POST
-H "Authorization: {{apiKey}}"
-H "Content-Type: multipart/form-data"
-H "Accept: application/json"
--form 'file=<string>'
https://api.easybill.de/rest/v1/attachments
Postman Collection Item JSON
{
"name": "Create attachment",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "multipart/form-data"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"value": "<string>",
"description": "(Required) ",
"type": "text"
}
]
},
"url": {
"raw": "{{baseUrl}}/attachments",
"host": [
"{{baseUrl}}"
],
"path": [
"attachments"
]
}
},
"response": [
{
"name": "Successful operation",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "multipart/form-data"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"value": "<string>",
"description": "(Required) ",
"type": "text"
}
]
},
"url": {
"raw": "{{baseUrl}}/attachments",
"host": [
"{{baseUrl}}"
],
"path": [
"attachments"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"created_at\": \"<date>\",\n \"customer_id\": null,\n \"document_id\": null,\n \"file_name\": \"<string>\",\n \"id\": \"<long>\",\n \"project_id\": null,\n \"size\": \"<integer>\"\n}"
},
{
"name": "Too Many Requests",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "multipart/form-data"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "file",
"value": "<string>",
"description": "(Required) ",
"type": "text"
}
]
},
"url": {
"raw": "{{baseUrl}}/attachments",
"host": [
"{{baseUrl}}"
],
"path": [
"attachments"
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}