Chilkat Online Tools

delphiDll / easybill REST API / Fetch position

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
v_number: PWideChar;
description: PWideChar;
sale_price: PWideChar;
id: PWideChar;
v_type: PWideChar;
document_note: PWideChar;
note: PWideChar;
unit: PWideChar;
export_identifier: PWideChar;
v_NULL: PWideChar;
NStb: PWideChar;
NStbUstID: PWideChar;
NStbNoneUstID: PWideChar;
NStbIm: PWideChar;
Revc: PWideChar;
IG: PWideChar;
AL: PWideChar;
SStfr: PWideChar;
SmallBusiness: PWideChar;
login_id: PWideChar;
price_type: PWideChar;
vat_percent: Integer;
sale_price2: PWideChar;
sale_price3: PWideChar;
sale_price4: PWideChar;
sale_price5: PWideChar;
sale_price6: PWideChar;
sale_price7: PWideChar;
sale_price8: PWideChar;
sale_price9: PWideChar;
sale_price10: PWideChar;
cost_price: PWideChar;
export_cost1: PWideChar;
export_cost2: PWideChar;
group_id: PWideChar;
stock: PWideChar;
stock_count: Integer;
stock_limit_notify: Boolean;
stock_limit_notify_frequency: PWideChar;
stock_limit: Integer;
quantity: PWideChar;
archived: Boolean;

begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

http := CkHttp_Create();

CkHttp_SetRequestHeader(http,'Authorization','{{apiKey}}');
CkHttp_SetRequestHeader(http,'Accept','application/json');

sbResponseBody := CkStringBuilder_Create();
success := CkHttp_QuickGetSb(http,'https://api.easybill.de/rest/v1/positions/:id',sbResponseBody);
if (success = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);

Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));

respStatusCode := CkHttp_getLastStatus(http);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkHttp__lastHeader(http));
    Memo1.Lines.Add('Failed.');
    Exit;
  end;

// 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

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);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);

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": ""
    }
  ]
}