Back to Collection Items
#include <CkHttp.h>
#include <CkStringBuilder.h>
#include <CkJsonObject.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http;
bool success;
http.SetRequestHeader("Authorization","{{apiKey}}");
http.SetRequestHeader("Accept","application/json");
CkStringBuilder sbResponseBody;
success = http.QuickGetSb("https://api.easybill.de/rest/v1/positions/:id",sbResponseBody);
if (success == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
CkJsonObject jResp;
jResp.LoadSb(sbResponseBody);
jResp.put_EmitCompact(false);
std::cout << "Response Body:" << "\r\n";
std::cout << jResp.emit() << "\r\n";
int respStatusCode = http.get_LastStatus();
std::cout << "Response Status Code = " << respStatusCode << "\r\n";
if (respStatusCode >= 400) {
std::cout << "Response Header:" << "\r\n";
std::cout << http.lastHeader() << "\r\n";
std::cout << "Failed." << "\r\n";
return;
}
// 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.
const char *v_number = jResp.stringOf("number");
const char *description = jResp.stringOf("description");
const char *sale_price = jResp.stringOf("sale_price");
const char *id = jResp.stringOf("id");
const char *v_type = jResp.stringOf("type");
const char *document_note = jResp.stringOf("document_note");
const char *note = jResp.stringOf("note");
const char *unit = jResp.stringOf("unit");
const char *export_identifier = jResp.stringOf("export_identifier");
const char *v_NULL = jResp.stringOf("export_identifier_extended.NULL");
const char *NStb = jResp.stringOf("export_identifier_extended.nStb");
const char *NStbUstID = jResp.stringOf("export_identifier_extended.nStbUstID");
const char *NStbNoneUstID = jResp.stringOf("export_identifier_extended.nStbNoneUstID");
const char *NStbIm = jResp.stringOf("export_identifier_extended.nStbIm");
const char *Revc = jResp.stringOf("export_identifier_extended.revc");
const char *IG = jResp.stringOf("export_identifier_extended.IG");
const char *AL = jResp.stringOf("export_identifier_extended.AL");
const char *SStfr = jResp.stringOf("export_identifier_extended.sStfr");
const char *SmallBusiness = jResp.stringOf("export_identifier_extended.smallBusiness");
const char *login_id = jResp.stringOf("login_id");
const char *price_type = jResp.stringOf("price_type");
int vat_percent = jResp.IntOf("vat_percent");
const char *sale_price2 = jResp.stringOf("sale_price2");
const char *sale_price3 = jResp.stringOf("sale_price3");
const char *sale_price4 = jResp.stringOf("sale_price4");
const char *sale_price5 = jResp.stringOf("sale_price5");
const char *sale_price6 = jResp.stringOf("sale_price6");
const char *sale_price7 = jResp.stringOf("sale_price7");
const char *sale_price8 = jResp.stringOf("sale_price8");
const char *sale_price9 = jResp.stringOf("sale_price9");
const char *sale_price10 = jResp.stringOf("sale_price10");
const char *cost_price = jResp.stringOf("cost_price");
const char *export_cost1 = jResp.stringOf("export_cost1");
const char *export_cost2 = jResp.stringOf("export_cost2");
const char *group_id = jResp.stringOf("group_id");
const char *stock = jResp.stringOf("stock");
int stock_count = jResp.IntOf("stock_count");
bool stock_limit_notify = jResp.BoolOf("stock_limit_notify");
const char *stock_limit_notify_frequency = jResp.stringOf("stock_limit_notify_frequency");
int stock_limit = jResp.IntOf("stock_limit");
const char *quantity = jResp.stringOf("quantity");
bool archived = jResp.BoolOf("archived");
}
Curl Command
curl -X GET
-H "Authorization: {{apiKey}}"
-H "Accept: application/json"
https://api.easybill.de/rest/v1/positions/:id
Postman Collection Item JSON
{
"name": "Fetch position",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/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": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"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": "Not found",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: apikey",
"key": "Authorization",
"value": "<API Key>"
}
],
"url": {
"raw": "{{baseUrl}}/positions/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"positions",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"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}}/positions/:id",
"host": [
"{{baseUrl}}"
],
"path": [
"positions",
":id"
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Too Many Requests",
"code": 429,
"_postman_previewlanguage": "text",
"header": [
],
"cookie": [
],
"body": ""
}
]
}