Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *v_number;
const wchar_t *description;
const wchar_t *sale_price;
const wchar_t *id;
const wchar_t *v_type;
const wchar_t *document_note;
const wchar_t *note;
const wchar_t *unit;
const wchar_t *export_identifier;
const wchar_t *v_NULL;
const wchar_t *NStb;
const wchar_t *NStbUstID;
const wchar_t *NStbNoneUstID;
const wchar_t *NStbIm;
const wchar_t *Revc;
const wchar_t *IG;
const wchar_t *AL;
const wchar_t *SStfr;
const wchar_t *SmallBusiness;
const wchar_t *login_id;
const wchar_t *price_type;
int vat_percent;
const wchar_t *sale_price2;
const wchar_t *sale_price3;
const wchar_t *sale_price4;
const wchar_t *sale_price5;
const wchar_t *sale_price6;
const wchar_t *sale_price7;
const wchar_t *sale_price8;
const wchar_t *sale_price9;
const wchar_t *sale_price10;
const wchar_t *cost_price;
const wchar_t *export_cost1;
const wchar_t *export_cost2;
const wchar_t *group_id;
const wchar_t *stock;
int stock_count;
BOOL stock_limit_notify;
const wchar_t *stock_limit_notify_frequency;
int stock_limit;
const wchar_t *quantity;
BOOL archived;
// 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.
// {
// "number": "<string>",
// "description": "<string>",
// "sale_price": "<float>",
// "id": "<long>",
// "type": "PRODUCT",
// "document_note": "<string>",
// "note": null,
// "unit": null,
// "export_identifier": null,
// "export_identifier_extended": {
// "NULL": null,
// "nStb": null,
// "nStbUstID": null,
// "nStbNoneUstID": null,
// "nStbIm": null,
// "revc": null,
// "IG": null,
// "AL": null,
// "sStfr": null,
// "smallBusiness": null
// },
// "login_id": "<long>",
// "price_type": "NETTO",
// "vat_percent": 19,
// "sale_price2": null,
// "sale_price3": null,
// "sale_price4": null,
// "sale_price5": null,
// "sale_price6": null,
// "sale_price7": null,
// "sale_price8": null,
// "sale_price9": null,
// "sale_price10": null,
// "cost_price": "<float>",
// "export_cost1": null,
// "export_cost2": null,
// "group_id": "<long>",
// "stock": "NO",
// "stock_count": 0,
// "stock_limit_notify": false,
// "stock_limit_notify_frequency": "ALWAYS",
// "stock_limit": 0,
// "quantity": null,
// "archived": false
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"number",L"<string>");
CkJsonObjectW_UpdateString(json,L"description",L"<string>");
CkJsonObjectW_UpdateString(json,L"sale_price",L"<float>");
CkJsonObjectW_UpdateString(json,L"id",L"<long>");
CkJsonObjectW_UpdateString(json,L"type",L"PRODUCT");
CkJsonObjectW_UpdateString(json,L"document_note",L"<string>");
CkJsonObjectW_UpdateNull(json,L"note");
CkJsonObjectW_UpdateNull(json,L"unit");
CkJsonObjectW_UpdateNull(json,L"export_identifier");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.NULL");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.nStb");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.nStbUstID");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.nStbNoneUstID");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.nStbIm");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.revc");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.IG");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.AL");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.sStfr");
CkJsonObjectW_UpdateNull(json,L"export_identifier_extended.smallBusiness");
CkJsonObjectW_UpdateString(json,L"login_id",L"<long>");
CkJsonObjectW_UpdateString(json,L"price_type",L"NETTO");
CkJsonObjectW_UpdateInt(json,L"vat_percent",19);
CkJsonObjectW_UpdateNull(json,L"sale_price2");
CkJsonObjectW_UpdateNull(json,L"sale_price3");
CkJsonObjectW_UpdateNull(json,L"sale_price4");
CkJsonObjectW_UpdateNull(json,L"sale_price5");
CkJsonObjectW_UpdateNull(json,L"sale_price6");
CkJsonObjectW_UpdateNull(json,L"sale_price7");
CkJsonObjectW_UpdateNull(json,L"sale_price8");
CkJsonObjectW_UpdateNull(json,L"sale_price9");
CkJsonObjectW_UpdateNull(json,L"sale_price10");
CkJsonObjectW_UpdateString(json,L"cost_price",L"<float>");
CkJsonObjectW_UpdateNull(json,L"export_cost1");
CkJsonObjectW_UpdateNull(json,L"export_cost2");
CkJsonObjectW_UpdateString(json,L"group_id",L"<long>");
CkJsonObjectW_UpdateString(json,L"stock",L"NO");
CkJsonObjectW_UpdateInt(json,L"stock_count",0);
CkJsonObjectW_UpdateBool(json,L"stock_limit_notify",FALSE);
CkJsonObjectW_UpdateString(json,L"stock_limit_notify_frequency",L"ALWAYS");
CkJsonObjectW_UpdateInt(json,L"stock_limit",0);
CkJsonObjectW_UpdateNull(json,L"quantity");
CkJsonObjectW_UpdateBool(json,L"archived",FALSE);
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
CkHttpW_SetRequestHeader(http,L"Authorization",L"{{apiKey}}");
CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");
resp = CkHttpW_PostJson3(http,L"https://api.easybill.de/rest/v1/positions",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
sbResponseBody = CkStringBuilderW_Create();
CkHttpResponseW_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpResponseW_getStatusCode(resp);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpResponseW_header(resp));
wprintf(L"Failed.\n");
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
CkHttpResponseW_Dispose(resp);
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "number": "<string>",
// "description": "<string>",
// "sale_price": "<float>",
// "id": "<long>",
// "type": "PRODUCT",
// "document_note": "<string>",
// "note": null,
// "unit": null,
// "export_identifier": null,
// "export_identifier_extended": {
// "NULL": null,
// "nStb": null,
// "nStbUstID": null,
// "nStbNoneUstID": null,
// "nStbIm": null,
// "revc": null,
// "IG": null,
// "AL": null,
// "sStfr": null,
// "smallBusiness": null
// },
// "login_id": "<long>",
// "price_type": "NETTO",
// "vat_percent": 19,
// "sale_price2": null,
// "sale_price3": null,
// "sale_price4": null,
// "sale_price5": null,
// "sale_price6": null,
// "sale_price7": null,
// "sale_price8": null,
// "sale_price9": null,
// "sale_price10": null,
// "cost_price": "<float>",
// "export_cost1": null,
// "export_cost2": null,
// "group_id": "<long>",
// "stock": "NO",
// "stock_count": 0,
// "stock_limit_notify": false,
// "stock_limit_notify_frequency": "ALWAYS",
// "stock_limit": 0,
// "quantity": null,
// "archived": false
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
v_number = CkJsonObjectW_stringOf(jResp,L"number");
description = CkJsonObjectW_stringOf(jResp,L"description");
sale_price = CkJsonObjectW_stringOf(jResp,L"sale_price");
id = CkJsonObjectW_stringOf(jResp,L"id");
v_type = CkJsonObjectW_stringOf(jResp,L"type");
document_note = CkJsonObjectW_stringOf(jResp,L"document_note");
note = CkJsonObjectW_stringOf(jResp,L"note");
unit = CkJsonObjectW_stringOf(jResp,L"unit");
export_identifier = CkJsonObjectW_stringOf(jResp,L"export_identifier");
v_NULL = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.NULL");
NStb = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.nStb");
NStbUstID = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.nStbUstID");
NStbNoneUstID = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.nStbNoneUstID");
NStbIm = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.nStbIm");
Revc = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.revc");
IG = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.IG");
AL = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.AL");
SStfr = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.sStfr");
SmallBusiness = CkJsonObjectW_stringOf(jResp,L"export_identifier_extended.smallBusiness");
login_id = CkJsonObjectW_stringOf(jResp,L"login_id");
price_type = CkJsonObjectW_stringOf(jResp,L"price_type");
vat_percent = CkJsonObjectW_IntOf(jResp,L"vat_percent");
sale_price2 = CkJsonObjectW_stringOf(jResp,L"sale_price2");
sale_price3 = CkJsonObjectW_stringOf(jResp,L"sale_price3");
sale_price4 = CkJsonObjectW_stringOf(jResp,L"sale_price4");
sale_price5 = CkJsonObjectW_stringOf(jResp,L"sale_price5");
sale_price6 = CkJsonObjectW_stringOf(jResp,L"sale_price6");
sale_price7 = CkJsonObjectW_stringOf(jResp,L"sale_price7");
sale_price8 = CkJsonObjectW_stringOf(jResp,L"sale_price8");
sale_price9 = CkJsonObjectW_stringOf(jResp,L"sale_price9");
sale_price10 = CkJsonObjectW_stringOf(jResp,L"sale_price10");
cost_price = CkJsonObjectW_stringOf(jResp,L"cost_price");
export_cost1 = CkJsonObjectW_stringOf(jResp,L"export_cost1");
export_cost2 = CkJsonObjectW_stringOf(jResp,L"export_cost2");
group_id = CkJsonObjectW_stringOf(jResp,L"group_id");
stock = CkJsonObjectW_stringOf(jResp,L"stock");
stock_count = CkJsonObjectW_IntOf(jResp,L"stock_count");
stock_limit_notify = CkJsonObjectW_BoolOf(jResp,L"stock_limit_notify");
stock_limit_notify_frequency = CkJsonObjectW_stringOf(jResp,L"stock_limit_notify_frequency");
stock_limit = CkJsonObjectW_IntOf(jResp,L"stock_limit");
quantity = CkJsonObjectW_stringOf(jResp,L"quantity");
archived = CkJsonObjectW_BoolOf(jResp,L"archived");
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -X POST
-H "Authorization: {{apiKey}}"
-H "Content-Type: application/json"
-H "Accept: application/json"
-d '{
"number": "<string>",
"description": "<string>",
"sale_price": "<float>",
"id": "<long>",
"type": "PRODUCT",
"document_note": "<string>",
"note": null,
"unit": null,
"export_identifier": null,
"export_identifier_extended": {
"NULL": null,
"nStb": null,
"nStbUstID": null,
"nStbNoneUstID": null,
"nStbIm": null,
"revc": null,
"IG": null,
"AL": null,
"sStfr": null,
"smallBusiness": null
},
"login_id": "<long>",
"price_type": "NETTO",
"vat_percent": 19,
"sale_price2": null,
"sale_price3": null,
"sale_price4": null,
"sale_price5": null,
"sale_price6": null,
"sale_price7": null,
"sale_price8": null,
"sale_price9": null,
"sale_price10": null,
"cost_price": "<float>",
"export_cost1": null,
"export_cost2": null,
"group_id": "<long>",
"stock": "NO",
"stock_count": 0,
"stock_limit_notify": false,
"stock_limit_notify_frequency": "ALWAYS",
"stock_limit": 0,
"quantity": null,
"archived": false
}'
https://api.easybill.de/rest/v1/positions
Postman Collection Item JSON
{
"name": "Create position",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"number\": \"<string>\",\n \"description\": \"<string>\",\n \"sale_price\": \"<float>\",\n \"id\": \"<long>\",\n \"type\": \"PRODUCT\",\n \"document_note\": \"<string>\",\n \"note\": null,\n \"unit\": null,\n \"export_identifier\": null,\n \"export_identifier_extended\": {\n \"NULL\": null,\n \"nStb\": null,\n \"nStbUstID\": null,\n \"nStbNoneUstID\": null,\n \"nStbIm\": null,\n \"revc\": null,\n \"IG\": null,\n \"AL\": null,\n \"sStfr\": null,\n \"smallBusiness\": null\n },\n \"login_id\": \"<long>\",\n \"price_type\": \"NETTO\",\n \"vat_percent\": 19,\n \"sale_price2\": null,\n \"sale_price3\": null,\n \"sale_price4\": null,\n \"sale_price5\": null,\n \"sale_price6\": null,\n \"sale_price7\": null,\n \"sale_price8\": null,\n \"sale_price9\": null,\n \"sale_price10\": null,\n \"cost_price\": \"<float>\",\n \"export_cost1\": null,\n \"export_cost2\": null,\n \"group_id\": \"<long>\",\n \"stock\": \"NO\",\n \"stock_count\": 0,\n \"stock_limit_notify\": false,\n \"stock_limit_notify_frequency\": \"ALWAYS\",\n \"stock_limit\": 0,\n \"quantity\": null,\n \"archived\": false\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/positions",
"host": [
"{{baseUrl}}"
],
"path": [
"positions"
]
}
},
"response": [
{
"name": "Successful operation",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"number\": \"<string>\",\n \"description\": \"<string>\",\n \"sale_price\": \"<float>\",\n \"id\": \"<long>\",\n \"type\": \"PRODUCT\",\n \"document_note\": \"<string>\",\n \"note\": null,\n \"unit\": null,\n \"export_identifier\": null,\n \"export_identifier_extended\": {\n \"NULL\": null,\n \"nStb\": null,\n \"nStbUstID\": null,\n \"nStbNoneUstID\": null,\n \"nStbIm\": null,\n \"revc\": null,\n \"IG\": null,\n \"AL\": null,\n \"sStfr\": null,\n \"smallBusiness\": null\n },\n \"login_id\": \"<long>\",\n \"price_type\": \"NETTO\",\n \"vat_percent\": 19,\n \"sale_price2\": null,\n \"sale_price3\": null,\n \"sale_price4\": null,\n \"sale_price5\": null,\n \"sale_price6\": null,\n \"sale_price7\": null,\n \"sale_price8\": null,\n \"sale_price9\": null,\n \"sale_price10\": null,\n \"cost_price\": \"<float>\",\n \"export_cost1\": null,\n \"export_cost2\": null,\n \"group_id\": \"<long>\",\n \"stock\": \"NO\",\n \"stock_count\": 0,\n \"stock_limit_notify\": false,\n \"stock_limit_notify_frequency\": \"ALWAYS\",\n \"stock_limit\": 0,\n \"quantity\": null,\n \"archived\": false\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/positions",
"host": [
"{{baseUrl}}"
],
"path": [
"positions"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"number\": \"<string>\",\n \"description\": \"<string>\",\n \"sale_price\": \"<float>\",\n \"id\": \"<long>\",\n \"type\": \"PRODUCT\",\n \"document_note\": \"<string>\",\n \"note\": null,\n \"unit\": null,\n \"export_identifier\": null,\n \"export_identifier_extended\": {\n \"NULL\": null,\n \"nStb\": null,\n \"nStbUstID\": null,\n \"nStbNoneUstID\": null,\n \"nStbIm\": null,\n \"revc\": null,\n \"IG\": null,\n \"AL\": null,\n \"sStfr\": null,\n \"smallBusiness\": null\n },\n \"login_id\": \"<long>\",\n \"price_type\": \"NETTO\",\n \"vat_percent\": 19,\n \"sale_price2\": null,\n \"sale_price3\": null,\n \"sale_price4\": null,\n \"sale_price5\": null,\n \"sale_price6\": null,\n \"sale_price7\": null,\n \"sale_price8\": null,\n \"sale_price9\": null,\n \"sale_price10\": null,\n \"cost_price\": \"<float>\",\n \"export_cost1\": null,\n \"export_cost2\": null,\n \"group_id\": \"<long>\",\n \"stock\": \"NO\",\n \"stock_count\": 0,\n \"stock_limit_notify\": false,\n \"stock_limit_notify_frequency\": \"ALWAYS\",\n \"stock_limit\": 0,\n \"quantity\": null,\n \"archived\": false\n}"
},
{
"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 \"number\": \"<string>\",\n \"description\": \"<string>\",\n \"sale_price\": \"<float>\",\n \"id\": \"<long>\",\n \"type\": \"PRODUCT\",\n \"document_note\": \"<string>\",\n \"note\": null,\n \"unit\": null,\n \"export_identifier\": null,\n \"export_identifier_extended\": {\n \"NULL\": null,\n \"nStb\": null,\n \"nStbUstID\": null,\n \"nStbNoneUstID\": null,\n \"nStbIm\": null,\n \"revc\": null,\n \"IG\": null,\n \"AL\": null,\n \"sStfr\": null,\n \"smallBusiness\": null\n },\n \"login_id\": \"<long>\",\n \"price_type\": \"NETTO\",\n \"vat_percent\": 19,\n \"sale_price2\": null,\n \"sale_price3\": null,\n \"sale_price4\": null,\n \"sale_price5\": null,\n \"sale_price6\": null,\n \"sale_price7\": null,\n \"sale_price8\": null,\n \"sale_price9\": null,\n \"sale_price10\": null,\n \"cost_price\": \"<float>\",\n \"export_cost1\": null,\n \"export_cost2\": null,\n \"group_id\": \"<long>\",\n \"stock\": \"NO\",\n \"stock_count\": 0,\n \"stock_limit_notify\": false,\n \"stock_limit_notify_frequency\": \"ALWAYS\",\n \"stock_limit\": 0,\n \"quantity\": null,\n \"archived\": false\n}",
"options": {
"raw": {
"headerFamily": "json",
"language": "json"
}
}
},
"url": {
"raw": "{{baseUrl}}/positions",
"host": [
"{{baseUrl}}"
],
"path": [
"positions"
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}