Chilkat Online Tools

TCL / easybill REST API / Fetch positions list

Back to Collection Items

load ./chilkat.dll

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

set http [new_CkHttp]

set queryParams [new_CkJsonObject]

CkJsonObject_UpdateString $queryParams "limit" "<integer>"
CkJsonObject_UpdateString $queryParams "page" "<integer>"
CkJsonObject_UpdateString $queryParams "type" "PRODUCT"
CkJsonObject_UpdateString $queryParams "number" "<string>"

CkHttp_SetRequestHeader $http "Authorization" "{{apiKey}}"
CkHttp_SetRequestHeader $http "Accept" "application/json"

# resp is a CkHttpResponse
set resp [CkHttp_QuickRequestParams $http "GET" "https://api.easybill.de/rest/v1/positions" $queryParams]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $queryParams
    exit
}

set sbResponseBody [new_CkStringBuilder]

CkHttpResponse_GetBodySb $resp $sbResponseBody

set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $sbResponseBody
CkJsonObject_put_EmitCompact $jResp 0

puts "Response Body:"
puts [CkJsonObject_emit $jResp]

set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttpResponse_header $resp]
    puts "Failed."
    delete_CkHttpResponse $resp

    delete_CkHttp $http
    delete_CkJsonObject $queryParams
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $jResp
    exit
}

delete_CkHttpResponse $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

set page [CkJsonObject_stringOf $jResp "page"]
set pages [CkJsonObject_stringOf $jResp "pages"]
set limit [CkJsonObject_stringOf $jResp "limit"]
set total [CkJsonObject_stringOf $jResp "total"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "items"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set v_number [CkJsonObject_stringOf $jResp "items[i].number"]
    set description [CkJsonObject_stringOf $jResp "items[i].description"]
    set sale_price [CkJsonObject_stringOf $jResp "items[i].sale_price"]
    set id [CkJsonObject_stringOf $jResp "items[i].id"]
    set v_type [CkJsonObject_stringOf $jResp "items[i].type"]
    set document_note [CkJsonObject_stringOf $jResp "items[i].document_note"]
    set note [CkJsonObject_stringOf $jResp "items[i].note"]
    set unit [CkJsonObject_stringOf $jResp "items[i].unit"]
    set export_identifier [CkJsonObject_stringOf $jResp "items[i].export_identifier"]
    set v_NULL [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.NULL"]
    set NStb [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.nStb"]
    set NStbUstID [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.nStbUstID"]
    set NStbNoneUstID [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.nStbNoneUstID"]
    set NStbIm [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.nStbIm"]
    set Revc [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.revc"]
    set IG [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.IG"]
    set AL [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.AL"]
    set SStfr [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.sStfr"]
    set SmallBusiness [CkJsonObject_stringOf $jResp "items[i].export_identifier_extended.smallBusiness"]
    set login_id [CkJsonObject_stringOf $jResp "items[i].login_id"]
    set price_type [CkJsonObject_stringOf $jResp "items[i].price_type"]
    set vat_percent [CkJsonObject_IntOf $jResp "items[i].vat_percent"]
    set sale_price2 [CkJsonObject_stringOf $jResp "items[i].sale_price2"]
    set sale_price3 [CkJsonObject_stringOf $jResp "items[i].sale_price3"]
    set sale_price4 [CkJsonObject_stringOf $jResp "items[i].sale_price4"]
    set sale_price5 [CkJsonObject_stringOf $jResp "items[i].sale_price5"]
    set sale_price6 [CkJsonObject_stringOf $jResp "items[i].sale_price6"]
    set sale_price7 [CkJsonObject_stringOf $jResp "items[i].sale_price7"]
    set sale_price8 [CkJsonObject_stringOf $jResp "items[i].sale_price8"]
    set sale_price9 [CkJsonObject_stringOf $jResp "items[i].sale_price9"]
    set sale_price10 [CkJsonObject_stringOf $jResp "items[i].sale_price10"]
    set cost_price [CkJsonObject_stringOf $jResp "items[i].cost_price"]
    set export_cost1 [CkJsonObject_stringOf $jResp "items[i].export_cost1"]
    set export_cost2 [CkJsonObject_stringOf $jResp "items[i].export_cost2"]
    set group_id [CkJsonObject_stringOf $jResp "items[i].group_id"]
    set stock [CkJsonObject_stringOf $jResp "items[i].stock"]
    set stock_count [CkJsonObject_IntOf $jResp "items[i].stock_count"]
    set stock_limit_notify [CkJsonObject_BoolOf $jResp "items[i].stock_limit_notify"]
    set stock_limit_notify_frequency [CkJsonObject_stringOf $jResp "items[i].stock_limit_notify_frequency"]
    set stock_limit [CkJsonObject_IntOf $jResp "items[i].stock_limit"]
    set quantity [CkJsonObject_stringOf $jResp "items[i].quantity"]
    set archived [CkJsonObject_BoolOf $jResp "items[i].archived"]
    set i [expr $i + 1]
}

delete_CkHttp $http
delete_CkJsonObject $queryParams
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp

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