Chilkat Online Tools

autoit / easybill REST API / Update position

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

; Use this online tool to generate code from sample JSON: Generate Code to Create JSON

; The following JSON is sent in the request body.

; {
;   "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
; }

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.UpdateString("number","<string>")
$oJson.UpdateString("description","<string>")
$oJson.UpdateString("sale_price","<float>")
$oJson.UpdateString("id","<long>")
$oJson.UpdateString("type","PRODUCT")
$oJson.UpdateString("document_note","<string>")
$oJson.UpdateNull("note")
$oJson.UpdateNull("unit")
$oJson.UpdateNull("export_identifier")
$oJson.UpdateNull("export_identifier_extended.NULL")
$oJson.UpdateNull("export_identifier_extended.nStb")
$oJson.UpdateNull("export_identifier_extended.nStbUstID")
$oJson.UpdateNull("export_identifier_extended.nStbNoneUstID")
$oJson.UpdateNull("export_identifier_extended.nStbIm")
$oJson.UpdateNull("export_identifier_extended.revc")
$oJson.UpdateNull("export_identifier_extended.IG")
$oJson.UpdateNull("export_identifier_extended.AL")
$oJson.UpdateNull("export_identifier_extended.sStfr")
$oJson.UpdateNull("export_identifier_extended.smallBusiness")
$oJson.UpdateString("login_id","<long>")
$oJson.UpdateString("price_type","NETTO")
$oJson.UpdateInt("vat_percent",19)
$oJson.UpdateNull("sale_price2")
$oJson.UpdateNull("sale_price3")
$oJson.UpdateNull("sale_price4")
$oJson.UpdateNull("sale_price5")
$oJson.UpdateNull("sale_price6")
$oJson.UpdateNull("sale_price7")
$oJson.UpdateNull("sale_price8")
$oJson.UpdateNull("sale_price9")
$oJson.UpdateNull("sale_price10")
$oJson.UpdateString("cost_price","<float>")
$oJson.UpdateNull("export_cost1")
$oJson.UpdateNull("export_cost2")
$oJson.UpdateString("group_id","<long>")
$oJson.UpdateString("stock","NO")
$oJson.UpdateInt("stock_count",0)
$oJson.UpdateBool("stock_limit_notify",False)
$oJson.UpdateString("stock_limit_notify_frequency","ALWAYS")
$oJson.UpdateInt("stock_limit",0)
$oJson.UpdateNull("quantity")
$oJson.UpdateBool("archived",False)

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

$oSbRequestBody = ObjCreate("Chilkat.StringBuilder")
$oJson.EmitSb($oSbRequestBody)

Local $oResp = $oHttp.PTextSb("PUT","https://api.easybill.de/rest/v1/positions/:id",$oSbRequestBody,"utf-8","application/json",False,False)
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)

; {
;   "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 = $oJResp.StringOf("number")
Local $sDescription = $oJResp.StringOf("description")
Local $sale_price = $oJResp.StringOf("sale_price")
Local $sId = $oJResp.StringOf("id")
Local $sV_type = $oJResp.StringOf("type")
Local $sDocument_note = $oJResp.StringOf("document_note")
Local $sNote = $oJResp.StringOf("note")
Local $sUnit = $oJResp.StringOf("unit")
Local $sExport_identifier = $oJResp.StringOf("export_identifier")
Local $sV_NULL = $oJResp.StringOf("export_identifier_extended.NULL")
Local $sNStb = $oJResp.StringOf("export_identifier_extended.nStb")
Local $sNStbUstID = $oJResp.StringOf("export_identifier_extended.nStbUstID")
Local $sNStbNoneUstID = $oJResp.StringOf("export_identifier_extended.nStbNoneUstID")
Local $sNStbIm = $oJResp.StringOf("export_identifier_extended.nStbIm")
Local $sRevc = $oJResp.StringOf("export_identifier_extended.revc")
Local $sIG = $oJResp.StringOf("export_identifier_extended.IG")
Local $sAL = $oJResp.StringOf("export_identifier_extended.AL")
Local $sSStfr = $oJResp.StringOf("export_identifier_extended.sStfr")
Local $sSmallBusiness = $oJResp.StringOf("export_identifier_extended.smallBusiness")
Local $sLogin_id = $oJResp.StringOf("login_id")
Local $sPrice_type = $oJResp.StringOf("price_type")
Local $iVat_percent = $oJResp.IntOf("vat_percent")
Local $sale_price2 = $oJResp.StringOf("sale_price2")
Local $sale_price3 = $oJResp.StringOf("sale_price3")
Local $sale_price4 = $oJResp.StringOf("sale_price4")
Local $sale_price5 = $oJResp.StringOf("sale_price5")
Local $sale_price6 = $oJResp.StringOf("sale_price6")
Local $sale_price7 = $oJResp.StringOf("sale_price7")
Local $sale_price8 = $oJResp.StringOf("sale_price8")
Local $sale_price9 = $oJResp.StringOf("sale_price9")
Local $sale_price10 = $oJResp.StringOf("sale_price10")
Local $sCost_price = $oJResp.StringOf("cost_price")
Local $sExport_cost1 = $oJResp.StringOf("export_cost1")
Local $sExport_cost2 = $oJResp.StringOf("export_cost2")
Local $sGroup_id = $oJResp.StringOf("group_id")
Local $stock = $oJResp.StringOf("stock")
Local $iStock_count = $oJResp.IntOf("stock_count")
Local $bStock_limit_notify = $oJResp.BoolOf("stock_limit_notify")
Local $stock_limit_notify_frequency = $oJResp.StringOf("stock_limit_notify_frequency")
Local $iStock_limit = $oJResp.IntOf("stock_limit")
Local $sQuantity = $oJResp.StringOf("quantity")
Local $bArchived = $oJResp.BoolOf("archived")

Curl Command

curl -X PUT
	-H "Authorization: {{apiKey}}"
	-H "Content-Type: application/json"
	-H "Accept: application/json"
	-d '{
  "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
}'
https://api.easybill.de/rest/v1/positions/:id

Postman Collection Item JSON

{
  "name": "Update position",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\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}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "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": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\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}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "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": "Invalid position",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\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}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/positions/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "positions",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Too Many Requests",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\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}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "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": ""
    }
  ]
}