Chilkat Online Tools

Foxpro / easybill REST API / Update position

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loResp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcV_number
LOCAL lcDescription
LOCAL lcSale_price
LOCAL lcId
LOCAL lcV_type
LOCAL lcDocument_note
LOCAL lcNote
LOCAL lcUnit
LOCAL lcExport_identifier
LOCAL lcV_NULL
LOCAL lcNStb
LOCAL lcNStbUstID
LOCAL lcNStbNoneUstID
LOCAL lcNStbIm
LOCAL lcRevc
LOCAL lcIG
LOCAL lcAL
LOCAL lcSStfr
LOCAL lcSmallBusiness
LOCAL lcLogin_id
LOCAL lcPrice_type
LOCAL lnVat_percent
LOCAL lcSale_price2
LOCAL lcSale_price3
LOCAL lcSale_price4
LOCAL lcSale_price5
LOCAL lcSale_price6
LOCAL lcSale_price7
LOCAL lcSale_price8
LOCAL lcSale_price9
LOCAL lcSale_price10
LOCAL lcCost_price
LOCAL lcExport_cost1
LOCAL lcExport_cost2
LOCAL lcGroup_id
LOCAL lcStock
LOCAL lnStock_count
LOCAL lnStock_limit_notify
LOCAL lcStock_limit_notify_frequency
LOCAL lnStock_limit
LOCAL lcQuantity
LOCAL lnArchived

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

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

* 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
* }

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

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

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbRequestBody = CreateObject('Chilkat.StringBuilder')
loJson.EmitSb(loSbRequestBody)

loResp = loHttp.PTextSb("PUT","https://api.easybill.de/rest/v1/positions/:id",loSbRequestBody,"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    RELEASE loSbRequestBody
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder')
loSbResponseBody = CreateObject('Chilkat.StringBuilder')
loResp.GetBodySb(loSbResponseBody)

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "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 loJson
    RELEASE loSbRequestBody
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

RELEASE loResp

* 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

lcV_number = loJResp.StringOf("number")
lcDescription = loJResp.StringOf("description")
lcSale_price = loJResp.StringOf("sale_price")
lcId = loJResp.StringOf("id")
lcV_type = loJResp.StringOf("type")
lcDocument_note = loJResp.StringOf("document_note")
lcNote = loJResp.StringOf("note")
lcUnit = loJResp.StringOf("unit")
lcExport_identifier = loJResp.StringOf("export_identifier")
lcV_NULL = loJResp.StringOf("export_identifier_extended.NULL")
lcNStb = loJResp.StringOf("export_identifier_extended.nStb")
lcNStbUstID = loJResp.StringOf("export_identifier_extended.nStbUstID")
lcNStbNoneUstID = loJResp.StringOf("export_identifier_extended.nStbNoneUstID")
lcNStbIm = loJResp.StringOf("export_identifier_extended.nStbIm")
lcRevc = loJResp.StringOf("export_identifier_extended.revc")
lcIG = loJResp.StringOf("export_identifier_extended.IG")
lcAL = loJResp.StringOf("export_identifier_extended.AL")
lcSStfr = loJResp.StringOf("export_identifier_extended.sStfr")
lcSmallBusiness = loJResp.StringOf("export_identifier_extended.smallBusiness")
lcLogin_id = loJResp.StringOf("login_id")
lcPrice_type = loJResp.StringOf("price_type")
lnVat_percent = loJResp.IntOf("vat_percent")
lcSale_price2 = loJResp.StringOf("sale_price2")
lcSale_price3 = loJResp.StringOf("sale_price3")
lcSale_price4 = loJResp.StringOf("sale_price4")
lcSale_price5 = loJResp.StringOf("sale_price5")
lcSale_price6 = loJResp.StringOf("sale_price6")
lcSale_price7 = loJResp.StringOf("sale_price7")
lcSale_price8 = loJResp.StringOf("sale_price8")
lcSale_price9 = loJResp.StringOf("sale_price9")
lcSale_price10 = loJResp.StringOf("sale_price10")
lcCost_price = loJResp.StringOf("cost_price")
lcExport_cost1 = loJResp.StringOf("export_cost1")
lcExport_cost2 = loJResp.StringOf("export_cost2")
lcGroup_id = loJResp.StringOf("group_id")
lcStock = loJResp.StringOf("stock")
lnStock_count = loJResp.IntOf("stock_count")
lnStock_limit_notify = loJResp.BoolOf("stock_limit_notify")
lcStock_limit_notify_frequency = loJResp.StringOf("stock_limit_notify_frequency")
lnStock_limit = loJResp.IntOf("stock_limit")
lcQuantity = loJResp.StringOf("quantity")
lnArchived = loJResp.BoolOf("archived")

RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp

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