Chilkat Online Tools

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

$oHttp = ObjCreate("Chilkat.Http")
Local $bSuccess

$oQueryParams = ObjCreate("Chilkat.JsonObject")
$oQueryParams.UpdateString("limit","<integer>")
$oQueryParams.UpdateString("page","<integer>")
$oQueryParams.UpdateString("type","PRODUCT")
$oQueryParams.UpdateString("number","<string>")

$oHttp.SetRequestHeader "Authorization","{{apiKey}}"
$oHttp.SetRequestHeader "Accept","application/json"

Local $oResp = $oHttp.QuickRequestParams("GET","https://api.easybill.de/rest/v1/positions",$oQueryParams)
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)

$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oResp.Header & @CRLF)
    ConsoleWrite("Failed." & @CRLF)

    Exit
EndIf

; 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

Local $sV_number
Local $sDescription
Local $sale_price
Local $sId
Local $sV_type
Local $sDocument_note
Local $sNote
Local $sUnit
Local $sExport_identifier
Local $sV_NULL
Local $sNStb
Local $sNStbUstID
Local $sNStbNoneUstID
Local $sNStbIm
Local $sRevc
Local $sIG
Local $sAL
Local $sSStfr
Local $sSmallBusiness
Local $sLogin_id
Local $sPrice_type
Local $iVat_percent
Local $sale_price2
Local $sale_price3
Local $sale_price4
Local $sale_price5
Local $sale_price6
Local $sale_price7
Local $sale_price8
Local $sale_price9
Local $sale_price10
Local $sCost_price
Local $sExport_cost1
Local $sExport_cost2
Local $sGroup_id
Local $stock
Local $iStock_count
Local $bStock_limit_notify
Local $stock_limit_notify_frequency
Local $iStock_limit
Local $sQuantity
Local $bArchived

Local $sPage = $oJResp.StringOf("page")
Local $sPages = $oJResp.StringOf("pages")
Local $sLimit = $oJResp.StringOf("limit")
Local $sTotal = $oJResp.StringOf("total")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("items")
While $i < $iCount_i
    $oJResp.I = $i
    $sV_number = $oJResp.StringOf("items[i].number")
    $sDescription = $oJResp.StringOf("items[i].description")
    $sale_price = $oJResp.StringOf("items[i].sale_price")
    $sId = $oJResp.StringOf("items[i].id")
    $sV_type = $oJResp.StringOf("items[i].type")
    $sDocument_note = $oJResp.StringOf("items[i].document_note")
    $sNote = $oJResp.StringOf("items[i].note")
    $sUnit = $oJResp.StringOf("items[i].unit")
    $sExport_identifier = $oJResp.StringOf("items[i].export_identifier")
    $sV_NULL = $oJResp.StringOf("items[i].export_identifier_extended.NULL")
    $sNStb = $oJResp.StringOf("items[i].export_identifier_extended.nStb")
    $sNStbUstID = $oJResp.StringOf("items[i].export_identifier_extended.nStbUstID")
    $sNStbNoneUstID = $oJResp.StringOf("items[i].export_identifier_extended.nStbNoneUstID")
    $sNStbIm = $oJResp.StringOf("items[i].export_identifier_extended.nStbIm")
    $sRevc = $oJResp.StringOf("items[i].export_identifier_extended.revc")
    $sIG = $oJResp.StringOf("items[i].export_identifier_extended.IG")
    $sAL = $oJResp.StringOf("items[i].export_identifier_extended.AL")
    $sSStfr = $oJResp.StringOf("items[i].export_identifier_extended.sStfr")
    $sSmallBusiness = $oJResp.StringOf("items[i].export_identifier_extended.smallBusiness")
    $sLogin_id = $oJResp.StringOf("items[i].login_id")
    $sPrice_type = $oJResp.StringOf("items[i].price_type")
    $iVat_percent = $oJResp.IntOf("items[i].vat_percent")
    $sale_price2 = $oJResp.StringOf("items[i].sale_price2")
    $sale_price3 = $oJResp.StringOf("items[i].sale_price3")
    $sale_price4 = $oJResp.StringOf("items[i].sale_price4")
    $sale_price5 = $oJResp.StringOf("items[i].sale_price5")
    $sale_price6 = $oJResp.StringOf("items[i].sale_price6")
    $sale_price7 = $oJResp.StringOf("items[i].sale_price7")
    $sale_price8 = $oJResp.StringOf("items[i].sale_price8")
    $sale_price9 = $oJResp.StringOf("items[i].sale_price9")
    $sale_price10 = $oJResp.StringOf("items[i].sale_price10")
    $sCost_price = $oJResp.StringOf("items[i].cost_price")
    $sExport_cost1 = $oJResp.StringOf("items[i].export_cost1")
    $sExport_cost2 = $oJResp.StringOf("items[i].export_cost2")
    $sGroup_id = $oJResp.StringOf("items[i].group_id")
    $stock = $oJResp.StringOf("items[i].stock")
    $iStock_count = $oJResp.IntOf("items[i].stock_count")
    $bStock_limit_notify = $oJResp.BoolOf("items[i].stock_limit_notify")
    $stock_limit_notify_frequency = $oJResp.StringOf("items[i].stock_limit_notify_frequency")
    $iStock_limit = $oJResp.IntOf("items[i].stock_limit")
    $sQuantity = $oJResp.StringOf("items[i].quantity")
    $bArchived = $oJResp.BoolOf("items[i].archived")
    $i = $i + 1
Wend

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