Chilkat Online Tools

C++ / easybill REST API / Fetch positions list

Back to Collection Items

#include <CkHttp.h>
#include <CkJsonObject.h>
#include <CkHttpResponse.h>
#include <CkStringBuilder.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;

    CkJsonObject queryParams;
    queryParams.UpdateString("limit","<integer>");
    queryParams.UpdateString("page","<integer>");
    queryParams.UpdateString("type","PRODUCT");
    queryParams.UpdateString("number","<string>");

    http.SetRequestHeader("Authorization","{{apiKey}}");
    http.SetRequestHeader("Accept","application/json");

    CkHttpResponse *resp = http.QuickRequestParams("GET","https://api.easybill.de/rest/v1/positions",queryParams);
    if (http.get_LastMethodSuccess() == false) {
        std::cout << http.lastErrorText() << "\r\n";
        return;
    }

    CkStringBuilder sbResponseBody;
    resp->GetBodySb(sbResponseBody);

    CkJsonObject jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    std::cout << "Response Body:" << "\r\n";
    std::cout << jResp.emit() << "\r\n";

    int respStatusCode = resp->get_StatusCode();
    std::cout << "Response Status Code = " << respStatusCode << "\r\n";
    if (respStatusCode >= 400) {
        std::cout << "Response Header:" << "\r\n";
        std::cout << resp->header() << "\r\n";
        std::cout << "Failed." << "\r\n";
        delete resp;
        return;
    }

    delete resp;

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "page": "<integer>",
    //   "pages": "<integer>",
    //   "limit": "<integer>",
    //   "total": "<integer>",
    //   "items": [
    //     {
    //       "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
    //     },
    //     {
    //       "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 = 0;
    const char *description = 0;
    const char *sale_price = 0;
    const char *id = 0;
    const char *v_type = 0;
    const char *document_note = 0;
    const char *note = 0;
    const char *unit = 0;
    const char *export_identifier = 0;
    const char *v_NULL = 0;
    const char *NStb = 0;
    const char *NStbUstID = 0;
    const char *NStbNoneUstID = 0;
    const char *NStbIm = 0;
    const char *Revc = 0;
    const char *IG = 0;
    const char *AL = 0;
    const char *SStfr = 0;
    const char *SmallBusiness = 0;
    const char *login_id = 0;
    const char *price_type = 0;
    int vat_percent;
    const char *sale_price2 = 0;
    const char *sale_price3 = 0;
    const char *sale_price4 = 0;
    const char *sale_price5 = 0;
    const char *sale_price6 = 0;
    const char *sale_price7 = 0;
    const char *sale_price8 = 0;
    const char *sale_price9 = 0;
    const char *sale_price10 = 0;
    const char *cost_price = 0;
    const char *export_cost1 = 0;
    const char *export_cost2 = 0;
    const char *group_id = 0;
    const char *stock = 0;
    int stock_count;
    bool stock_limit_notify;
    const char *stock_limit_notify_frequency = 0;
    int stock_limit;
    const char *quantity = 0;
    bool archived;

    const char *page = jResp.stringOf("page");
    const char *pages = jResp.stringOf("pages");
    const char *limit = jResp.stringOf("limit");
    const char *total = jResp.stringOf("total");
    int i = 0;
    int count_i = jResp.SizeOfArray("items");
    while (i < count_i) {
        jResp.put_I(i);
        v_number = jResp.stringOf("items[i].number");
        description = jResp.stringOf("items[i].description");
        sale_price = jResp.stringOf("items[i].sale_price");
        id = jResp.stringOf("items[i].id");
        v_type = jResp.stringOf("items[i].type");
        document_note = jResp.stringOf("items[i].document_note");
        note = jResp.stringOf("items[i].note");
        unit = jResp.stringOf("items[i].unit");
        export_identifier = jResp.stringOf("items[i].export_identifier");
        v_NULL = jResp.stringOf("items[i].export_identifier_extended.NULL");
        NStb = jResp.stringOf("items[i].export_identifier_extended.nStb");
        NStbUstID = jResp.stringOf("items[i].export_identifier_extended.nStbUstID");
        NStbNoneUstID = jResp.stringOf("items[i].export_identifier_extended.nStbNoneUstID");
        NStbIm = jResp.stringOf("items[i].export_identifier_extended.nStbIm");
        Revc = jResp.stringOf("items[i].export_identifier_extended.revc");
        IG = jResp.stringOf("items[i].export_identifier_extended.IG");
        AL = jResp.stringOf("items[i].export_identifier_extended.AL");
        SStfr = jResp.stringOf("items[i].export_identifier_extended.sStfr");
        SmallBusiness = jResp.stringOf("items[i].export_identifier_extended.smallBusiness");
        login_id = jResp.stringOf("items[i].login_id");
        price_type = jResp.stringOf("items[i].price_type");
        vat_percent = jResp.IntOf("items[i].vat_percent");
        sale_price2 = jResp.stringOf("items[i].sale_price2");
        sale_price3 = jResp.stringOf("items[i].sale_price3");
        sale_price4 = jResp.stringOf("items[i].sale_price4");
        sale_price5 = jResp.stringOf("items[i].sale_price5");
        sale_price6 = jResp.stringOf("items[i].sale_price6");
        sale_price7 = jResp.stringOf("items[i].sale_price7");
        sale_price8 = jResp.stringOf("items[i].sale_price8");
        sale_price9 = jResp.stringOf("items[i].sale_price9");
        sale_price10 = jResp.stringOf("items[i].sale_price10");
        cost_price = jResp.stringOf("items[i].cost_price");
        export_cost1 = jResp.stringOf("items[i].export_cost1");
        export_cost2 = jResp.stringOf("items[i].export_cost2");
        group_id = jResp.stringOf("items[i].group_id");
        stock = jResp.stringOf("items[i].stock");
        stock_count = jResp.IntOf("items[i].stock_count");
        stock_limit_notify = jResp.BoolOf("items[i].stock_limit_notify");
        stock_limit_notify_frequency = jResp.stringOf("items[i].stock_limit_notify_frequency");
        stock_limit = jResp.IntOf("items[i].stock_limit");
        quantity = jResp.stringOf("items[i].quantity");
        archived = jResp.BoolOf("items[i].archived");
        i = i + 1;
    }
    }

Curl Command

curl -G -d "limit=%3Cinteger%3E"
	-d "page=%3Cinteger%3E"
	-d "type=PRODUCT"
	-d "number=%3Cstring%3E"
	-H "Authorization: {{apiKey}}"
	-H "Accept: application/json"
https://api.easybill.de/rest/v1/positions

Postman Collection Item JSON

{
  "name": "Fetch positions list",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/positions?limit=<integer>&page=<integer>&type=PRODUCT&number=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "positions"
      ],
      "query": [
        {
          "key": "limit",
          "value": "<integer>",
          "description": "Limited the result. Default is 100. Maximum can be 1000."
        },
        {
          "key": "page",
          "value": "<integer>",
          "description": "Set current Page. Default is 1."
        },
        {
          "key": "type",
          "value": "PRODUCT",
          "description": "Filter positions by type."
        },
        {
          "key": "number",
          "value": "<string>",
          "description": "Filter positions by number. You can add multiple numbers separate by comma like no,no,no."
        }
      ]
    }
  },
  "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?limit=<integer>&page=<integer>&type=PRODUCT&number=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "positions"
          ],
          "query": [
            {
              "key": "limit",
              "value": "<integer>",
              "description": "Limited the result. Default is 100. Maximum can be 1000."
            },
            {
              "key": "page",
              "value": "<integer>",
              "description": "Set current Page. Default is 1."
            },
            {
              "key": "type",
              "value": "PRODUCT",
              "description": "Filter positions by type."
            },
            {
              "key": "number",
              "value": "<string>",
              "description": "Filter positions by number. You can add multiple numbers separate by comma like no,no,no."
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"page\": \"<integer>\",\n  \"pages\": \"<integer>\",\n  \"limit\": \"<integer>\",\n  \"total\": \"<integer>\",\n  \"items\": [\n    {\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    },\n    {\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    }\n  ]\n}"
    },
    {
      "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?limit=<integer>&page=<integer>&type=PRODUCT&number=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "positions"
          ],
          "query": [
            {
              "key": "limit",
              "value": "<integer>",
              "description": "Limited the result. Default is 100. Maximum can be 1000."
            },
            {
              "key": "page",
              "value": "<integer>",
              "description": "Set current Page. Default is 1."
            },
            {
              "key": "type",
              "value": "PRODUCT",
              "description": "Filter positions by type."
            },
            {
              "key": "number",
              "value": "<string>",
              "description": "Filter positions by number. You can add multiple numbers separate by comma like no,no,no."
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}