Chilkat Online Tools

lianja / easybill REST API / Fetch positions list

Back to Collection Items

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

loHttp = createobject("CkHttp")

loQueryParams = createobject("CkJsonObject")
loQueryParams.UpdateString("limit","<integer>")
loQueryParams.UpdateString("page","<integer>")
loQueryParams.UpdateString("type","PRODUCT")
loQueryParams.UpdateString("number","<string>")

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

loResp = loHttp.QuickRequestParams("GET","https://api.easybill.de/rest/v1/positions",loQueryParams)
if (loHttp.LastMethodSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loQueryParams
    return
endif

loSbResponseBody = createobject("CkStringBuilder")
loResp.GetBodySb(loSbResponseBody)

loJResp = createobject("CkJsonObject")
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = .F.

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + str(lnRespStatusCode)
if (lnRespStatusCode >= 400) then
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    release loResp
    release loHttp
    release loQueryParams
    release loSbResponseBody
    release loJResp
    return
endif

release loResp

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

lcPage = loJResp.StringOf("page")
lcPages = loJResp.StringOf("pages")
lcLimit = loJResp.StringOf("limit")
lcTotal = loJResp.StringOf("total")
i = 0
lnCount_i = loJResp.SizeOfArray("items")
do while i < lnCount_i
    loJResp.I = i
    lcV_number = loJResp.StringOf("items[i].number")
    lcDescription = loJResp.StringOf("items[i].description")
    lcSale_price = loJResp.StringOf("items[i].sale_price")
    lcId = loJResp.StringOf("items[i].id")
    lcV_type = loJResp.StringOf("items[i].type")
    lcDocument_note = loJResp.StringOf("items[i].document_note")
    lcNote = loJResp.StringOf("items[i].note")
    lcUnit = loJResp.StringOf("items[i].unit")
    lcExport_identifier = loJResp.StringOf("items[i].export_identifier")
    lcV_NULL = loJResp.StringOf("items[i].export_identifier_extended.NULL")
    lcNStb = loJResp.StringOf("items[i].export_identifier_extended.nStb")
    lcNStbUstID = loJResp.StringOf("items[i].export_identifier_extended.nStbUstID")
    lcNStbNoneUstID = loJResp.StringOf("items[i].export_identifier_extended.nStbNoneUstID")
    lcNStbIm = loJResp.StringOf("items[i].export_identifier_extended.nStbIm")
    lcRevc = loJResp.StringOf("items[i].export_identifier_extended.revc")
    lcIG = loJResp.StringOf("items[i].export_identifier_extended.IG")
    lcAL = loJResp.StringOf("items[i].export_identifier_extended.AL")
    lcSStfr = loJResp.StringOf("items[i].export_identifier_extended.sStfr")
    lcSmallBusiness = loJResp.StringOf("items[i].export_identifier_extended.smallBusiness")
    lcLogin_id = loJResp.StringOf("items[i].login_id")
    lcPrice_type = loJResp.StringOf("items[i].price_type")
    lnVat_percent = loJResp.IntOf("items[i].vat_percent")
    lcSale_price2 = loJResp.StringOf("items[i].sale_price2")
    lcSale_price3 = loJResp.StringOf("items[i].sale_price3")
    lcSale_price4 = loJResp.StringOf("items[i].sale_price4")
    lcSale_price5 = loJResp.StringOf("items[i].sale_price5")
    lcSale_price6 = loJResp.StringOf("items[i].sale_price6")
    lcSale_price7 = loJResp.StringOf("items[i].sale_price7")
    lcSale_price8 = loJResp.StringOf("items[i].sale_price8")
    lcSale_price9 = loJResp.StringOf("items[i].sale_price9")
    lcSale_price10 = loJResp.StringOf("items[i].sale_price10")
    lcCost_price = loJResp.StringOf("items[i].cost_price")
    lcExport_cost1 = loJResp.StringOf("items[i].export_cost1")
    lcExport_cost2 = loJResp.StringOf("items[i].export_cost2")
    lcGroup_id = loJResp.StringOf("items[i].group_id")
    lcStock = loJResp.StringOf("items[i].stock")
    lnStock_count = loJResp.IntOf("items[i].stock_count")
    llStock_limit_notify = loJResp.BoolOf("items[i].stock_limit_notify")
    lcStock_limit_notify_frequency = loJResp.StringOf("items[i].stock_limit_notify_frequency")
    lnStock_limit = loJResp.IntOf("items[i].stock_limit")
    lcQuantity = loJResp.StringOf("items[i].quantity")
    llArchived = loJResp.BoolOf("items[i].archived")
    i = i + 1
enddo


release loHttp
release loQueryParams
release loSbResponseBody
release loJResp

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