Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkStringBuilder.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject json;
HCkStringBuilder sbRequestBody;
HCkHttpResponse resp;
HCkStringBuilder sbResponseBody;
HCkJsonObject jResp;
int respStatusCode;
const char *v_number;
const char *description;
const char *sale_price;
const char *id;
const char *v_type;
const char *document_note;
const char *note;
const char *unit;
const char *export_identifier;
const char *v_NULL;
const char *NStb;
const char *NStbUstID;
const char *NStbNoneUstID;
const char *NStbIm;
const char *Revc;
const char *IG;
const char *AL;
const char *SStfr;
const char *SmallBusiness;
const char *login_id;
const char *price_type;
int vat_percent;
const char *sale_price2;
const char *sale_price3;
const char *sale_price4;
const char *sale_price5;
const char *sale_price6;
const char *sale_price7;
const char *sale_price8;
const char *sale_price9;
const char *sale_price10;
const char *cost_price;
const char *export_cost1;
const char *export_cost2;
const char *group_id;
const char *stock;
int stock_count;
BOOL stock_limit_notify;
const char *stock_limit_notify_frequency;
int stock_limit;
const char *quantity;
BOOL archived;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_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 = CkJsonObject_Create();
CkJsonObject_UpdateString(json,"number","<string>");
CkJsonObject_UpdateString(json,"description","<string>");
CkJsonObject_UpdateString(json,"sale_price","<float>");
CkJsonObject_UpdateString(json,"id","<long>");
CkJsonObject_UpdateString(json,"type","PRODUCT");
CkJsonObject_UpdateString(json,"document_note","<string>");
CkJsonObject_UpdateNull(json,"note");
CkJsonObject_UpdateNull(json,"unit");
CkJsonObject_UpdateNull(json,"export_identifier");
CkJsonObject_UpdateNull(json,"export_identifier_extended.NULL");
CkJsonObject_UpdateNull(json,"export_identifier_extended.nStb");
CkJsonObject_UpdateNull(json,"export_identifier_extended.nStbUstID");
CkJsonObject_UpdateNull(json,"export_identifier_extended.nStbNoneUstID");
CkJsonObject_UpdateNull(json,"export_identifier_extended.nStbIm");
CkJsonObject_UpdateNull(json,"export_identifier_extended.revc");
CkJsonObject_UpdateNull(json,"export_identifier_extended.IG");
CkJsonObject_UpdateNull(json,"export_identifier_extended.AL");
CkJsonObject_UpdateNull(json,"export_identifier_extended.sStfr");
CkJsonObject_UpdateNull(json,"export_identifier_extended.smallBusiness");
CkJsonObject_UpdateString(json,"login_id","<long>");
CkJsonObject_UpdateString(json,"price_type","NETTO");
CkJsonObject_UpdateInt(json,"vat_percent",19);
CkJsonObject_UpdateNull(json,"sale_price2");
CkJsonObject_UpdateNull(json,"sale_price3");
CkJsonObject_UpdateNull(json,"sale_price4");
CkJsonObject_UpdateNull(json,"sale_price5");
CkJsonObject_UpdateNull(json,"sale_price6");
CkJsonObject_UpdateNull(json,"sale_price7");
CkJsonObject_UpdateNull(json,"sale_price8");
CkJsonObject_UpdateNull(json,"sale_price9");
CkJsonObject_UpdateNull(json,"sale_price10");
CkJsonObject_UpdateString(json,"cost_price","<float>");
CkJsonObject_UpdateNull(json,"export_cost1");
CkJsonObject_UpdateNull(json,"export_cost2");
CkJsonObject_UpdateString(json,"group_id","<long>");
CkJsonObject_UpdateString(json,"stock","NO");
CkJsonObject_UpdateInt(json,"stock_count",0);
CkJsonObject_UpdateBool(json,"stock_limit_notify",FALSE);
CkJsonObject_UpdateString(json,"stock_limit_notify_frequency","ALWAYS");
CkJsonObject_UpdateInt(json,"stock_limit",0);
CkJsonObject_UpdateNull(json,"quantity");
CkJsonObject_UpdateBool(json,"archived",FALSE);
CkHttp_SetRequestHeader(http,"Content-Type","application/json");
CkHttp_SetRequestHeader(http,"Authorization","{{apiKey}}");
CkHttp_SetRequestHeader(http,"Accept","application/json");
sbRequestBody = CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);
resp = CkHttp_PTextSb(http,"PUT","https://api.easybill.de/rest/v1/positions/:id",sbRequestBody,"utf-8","application/json",FALSE,FALSE);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
return;
}
sbResponseBody = CkStringBuilder_Create();
CkHttpResponse_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,FALSE);
printf("Response Body:\n");
printf("%s\n",CkJsonObject_emit(jResp));
respStatusCode = CkHttpResponse_getStatusCode(resp);
printf("Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
printf("Response Header:\n");
printf("%s\n",CkHttpResponse_header(resp));
printf("Failed.\n");
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
return;
}
CkHttpResponse_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 = CkJsonObject_stringOf(jResp,"number");
description = CkJsonObject_stringOf(jResp,"description");
sale_price = CkJsonObject_stringOf(jResp,"sale_price");
id = CkJsonObject_stringOf(jResp,"id");
v_type = CkJsonObject_stringOf(jResp,"type");
document_note = CkJsonObject_stringOf(jResp,"document_note");
note = CkJsonObject_stringOf(jResp,"note");
unit = CkJsonObject_stringOf(jResp,"unit");
export_identifier = CkJsonObject_stringOf(jResp,"export_identifier");
v_NULL = CkJsonObject_stringOf(jResp,"export_identifier_extended.NULL");
NStb = CkJsonObject_stringOf(jResp,"export_identifier_extended.nStb");
NStbUstID = CkJsonObject_stringOf(jResp,"export_identifier_extended.nStbUstID");
NStbNoneUstID = CkJsonObject_stringOf(jResp,"export_identifier_extended.nStbNoneUstID");
NStbIm = CkJsonObject_stringOf(jResp,"export_identifier_extended.nStbIm");
Revc = CkJsonObject_stringOf(jResp,"export_identifier_extended.revc");
IG = CkJsonObject_stringOf(jResp,"export_identifier_extended.IG");
AL = CkJsonObject_stringOf(jResp,"export_identifier_extended.AL");
SStfr = CkJsonObject_stringOf(jResp,"export_identifier_extended.sStfr");
SmallBusiness = CkJsonObject_stringOf(jResp,"export_identifier_extended.smallBusiness");
login_id = CkJsonObject_stringOf(jResp,"login_id");
price_type = CkJsonObject_stringOf(jResp,"price_type");
vat_percent = CkJsonObject_IntOf(jResp,"vat_percent");
sale_price2 = CkJsonObject_stringOf(jResp,"sale_price2");
sale_price3 = CkJsonObject_stringOf(jResp,"sale_price3");
sale_price4 = CkJsonObject_stringOf(jResp,"sale_price4");
sale_price5 = CkJsonObject_stringOf(jResp,"sale_price5");
sale_price6 = CkJsonObject_stringOf(jResp,"sale_price6");
sale_price7 = CkJsonObject_stringOf(jResp,"sale_price7");
sale_price8 = CkJsonObject_stringOf(jResp,"sale_price8");
sale_price9 = CkJsonObject_stringOf(jResp,"sale_price9");
sale_price10 = CkJsonObject_stringOf(jResp,"sale_price10");
cost_price = CkJsonObject_stringOf(jResp,"cost_price");
export_cost1 = CkJsonObject_stringOf(jResp,"export_cost1");
export_cost2 = CkJsonObject_stringOf(jResp,"export_cost2");
group_id = CkJsonObject_stringOf(jResp,"group_id");
stock = CkJsonObject_stringOf(jResp,"stock");
stock_count = CkJsonObject_IntOf(jResp,"stock_count");
stock_limit_notify = CkJsonObject_BoolOf(jResp,"stock_limit_notify");
stock_limit_notify_frequency = CkJsonObject_stringOf(jResp,"stock_limit_notify_frequency");
stock_limit = CkJsonObject_IntOf(jResp,"stock_limit");
quantity = CkJsonObject_stringOf(jResp,"quantity");
archived = CkJsonObject_BoolOf(jResp,"archived");
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
}
Curl Command
curl -X PUT
-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/:id
Postman Collection Item JSON
{
"name": "Update position",
"request": {
"method": "PUT",
"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/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"positions",
":id"
],
"variable": [
{
"key": "id",
"value": "<long>",
"description": "(Required) ID of position"
}
]
}
},
"response": [
{
"name": "Successful operation",
"originalRequest": {
"method": "PUT",
"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/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"positions",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "OK",
"code": 200,
"_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": "Invalid position",
"originalRequest": {
"method": "PUT",
"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/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"positions",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
},
{
"name": "Too Many Requests",
"originalRequest": {
"method": "PUT",
"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/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"positions",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}