Chilkat Online Tools

unicodeCpp / easybill REST API / Fetch position

Back to Collection Items

#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttpW http;
    bool success;

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

    CkStringBuilderW sbResponseBody;
    success = http.QuickGetSb(L"https://api.easybill.de/rest/v1/positions/:id",sbResponseBody);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

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

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = http.get_LastStatus();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",http.lastHeader());
        wprintf(L"Failed.\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 wchar_t *v_number = jResp.stringOf(L"number");
    const wchar_t *description = jResp.stringOf(L"description");
    const wchar_t *sale_price = jResp.stringOf(L"sale_price");
    const wchar_t *id = jResp.stringOf(L"id");
    const wchar_t *v_type = jResp.stringOf(L"type");
    const wchar_t *document_note = jResp.stringOf(L"document_note");
    const wchar_t *note = jResp.stringOf(L"note");
    const wchar_t *unit = jResp.stringOf(L"unit");
    const wchar_t *export_identifier = jResp.stringOf(L"export_identifier");
    const wchar_t *v_NULL = jResp.stringOf(L"export_identifier_extended.NULL");
    const wchar_t *NStb = jResp.stringOf(L"export_identifier_extended.nStb");
    const wchar_t *NStbUstID = jResp.stringOf(L"export_identifier_extended.nStbUstID");
    const wchar_t *NStbNoneUstID = jResp.stringOf(L"export_identifier_extended.nStbNoneUstID");
    const wchar_t *NStbIm = jResp.stringOf(L"export_identifier_extended.nStbIm");
    const wchar_t *Revc = jResp.stringOf(L"export_identifier_extended.revc");
    const wchar_t *IG = jResp.stringOf(L"export_identifier_extended.IG");
    const wchar_t *AL = jResp.stringOf(L"export_identifier_extended.AL");
    const wchar_t *SStfr = jResp.stringOf(L"export_identifier_extended.sStfr");
    const wchar_t *SmallBusiness = jResp.stringOf(L"export_identifier_extended.smallBusiness");
    const wchar_t *login_id = jResp.stringOf(L"login_id");
    const wchar_t *price_type = jResp.stringOf(L"price_type");
    int vat_percent = jResp.IntOf(L"vat_percent");
    const wchar_t *sale_price2 = jResp.stringOf(L"sale_price2");
    const wchar_t *sale_price3 = jResp.stringOf(L"sale_price3");
    const wchar_t *sale_price4 = jResp.stringOf(L"sale_price4");
    const wchar_t *sale_price5 = jResp.stringOf(L"sale_price5");
    const wchar_t *sale_price6 = jResp.stringOf(L"sale_price6");
    const wchar_t *sale_price7 = jResp.stringOf(L"sale_price7");
    const wchar_t *sale_price8 = jResp.stringOf(L"sale_price8");
    const wchar_t *sale_price9 = jResp.stringOf(L"sale_price9");
    const wchar_t *sale_price10 = jResp.stringOf(L"sale_price10");
    const wchar_t *cost_price = jResp.stringOf(L"cost_price");
    const wchar_t *export_cost1 = jResp.stringOf(L"export_cost1");
    const wchar_t *export_cost2 = jResp.stringOf(L"export_cost2");
    const wchar_t *group_id = jResp.stringOf(L"group_id");
    const wchar_t *stock = jResp.stringOf(L"stock");
    int stock_count = jResp.IntOf(L"stock_count");
    bool stock_limit_notify = jResp.BoolOf(L"stock_limit_notify");
    const wchar_t *stock_limit_notify_frequency = jResp.stringOf(L"stock_limit_notify_frequency");
    int stock_limit = jResp.IntOf(L"stock_limit");
    const wchar_t *quantity = jResp.stringOf(L"quantity");
    bool archived = jResp.BoolOf(L"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": ""
    }
  ]
}