Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
int respStatusCode;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "to": "<string>",
// "cc": "<string>",
// "from": "<string>",
// "subject": "<string>",
// "message": "<string>",
// "date": "<date>",
// "send_by_self": "<boolean>",
// "send_with_attachment": "true",
// "document_file_type": "default",
// "post_send_type": "post_send_type_prio"
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"to",L"<string>");
CkJsonObjectW_UpdateString(json,L"cc",L"<string>");
CkJsonObjectW_UpdateString(json,L"from",L"<string>");
CkJsonObjectW_UpdateString(json,L"subject",L"<string>");
CkJsonObjectW_UpdateString(json,L"message",L"<string>");
CkJsonObjectW_UpdateString(json,L"date",L"<date>");
CkJsonObjectW_UpdateString(json,L"send_by_self",L"<boolean>");
CkJsonObjectW_UpdateString(json,L"send_with_attachment",L"true");
CkJsonObjectW_UpdateString(json,L"document_file_type",L"default");
CkJsonObjectW_UpdateString(json,L"post_send_type",L"post_send_type_prio");
CkHttpW_SetRequestHeader(http,L"Authorization",L"{{apiKey}}");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
resp = CkHttpW_PostJson3(http,L"https://api.easybill.de/rest/v1/documents/:id/send/:type",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
respStatusCode = CkHttpResponseW_getStatusCode(resp);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode != 204) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpResponseW_header(resp));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
wprintf(L"Failed.\n");
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
CkHttpResponseW_Dispose(resp);
wprintf(L"Success.\n");
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "Authorization: {{apiKey}}"
-H "Content-Type: application/json"
-d '{
"to": "<string>",
"cc": "<string>",
"from": "<string>",
"subject": "<string>",
"message": "<string>",
"date": "<date>",
"send_by_self": "<boolean>",
"send_with_attachment": "true",
"document_file_type": "default",
"post_send_type": "post_send_type_prio"
}'
https://api.easybill.de/rest/v1/documents/:id/send/:type
Postman Collection Item JSON
{
"name": "Send document",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"to\": \"<string>\",\n \"cc\": \"<string>\",\n \"from\": \"<string>\",\n \"subject\": \"<string>\",\n \"message\": \"<string>\",\n \"date\": \"<date>\",\n \"send_by_self\": \"<boolean>\",\n \"send_with_attachment\": \"true\",\n \"document_file_type\": \"default\",\n \"post_send_type\": \"post_send_type_prio\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/documents/:id/send/:type",
"host": [
"{{baseUrl}}"
],
"path": [
"documents",
":id",
"send",
":type"
],
"variable": [
{
"key": "id",
"value": "<long>",
"description": "(Required) ID of document"
},
{
"key": "type",
"value": "fax",
"description": "(Required) "
}
]
}
},
"response": [
{
"name": "Successful operation",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"to\": \"<string>\",\n \"cc\": \"<string>\",\n \"from\": \"<string>\",\n \"subject\": \"<string>\",\n \"message\": \"<string>\",\n \"date\": \"<date>\",\n \"send_by_self\": \"<boolean>\",\n \"send_with_attachment\": \"true\",\n \"document_file_type\": \"default\",\n \"post_send_type\": \"post_send_type_prio\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/documents/:id/send/:type",
"host": [
"{{baseUrl}}"
],
"path": [
"documents",
":id",
"send",
":type"
],
"variable": [
{
"key": "id"
},
{
"key": "type"
}
]
}
},
"status": "No Content",
"code": 204,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
},
{
"name": "Not found",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"to\": \"<string>\",\n \"cc\": \"<string>\",\n \"from\": \"<string>\",\n \"subject\": \"<string>\",\n \"message\": \"<string>\",\n \"date\": \"<date>\",\n \"send_by_self\": \"<boolean>\",\n \"send_with_attachment\": \"true\",\n \"document_file_type\": \"default\",\n \"post_send_type\": \"post_send_type_prio\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/documents/:id/send/:type",
"host": [
"{{baseUrl}}"
],
"path": [
"documents",
":id",
"send",
":type"
],
"variable": [
{
"key": "id"
},
{
"key": "type"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
},
{
"name": "Too Many Requests",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"to\": \"<string>\",\n \"cc\": \"<string>\",\n \"from\": \"<string>\",\n \"subject\": \"<string>\",\n \"message\": \"<string>\",\n \"date\": \"<date>\",\n \"send_by_self\": \"<boolean>\",\n \"send_with_attachment\": \"true\",\n \"document_file_type\": \"default\",\n \"post_send_type\": \"post_send_type_prio\"\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/documents/:id/send/:type",
"host": [
"{{baseUrl}}"
],
"path": [
"documents",
":id",
"send",
":type"
],
"variable": [
{
"key": "id"
},
{
"key": "type"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}