Chilkat Online Tools

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

loHttp = createobject("CkHttp")

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

loJson = createobject("CkJsonObject")
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",.F.)
loJson.UpdateString("stock_limit_notify_frequency","ALWAYS")
loJson.UpdateInt("stock_limit",0)
loJson.UpdateNull("quantity")
loJson.UpdateBool("archived",.F.)

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

loSbRequestBody = createobject("CkStringBuilder")
loJson.EmitSb(loSbRequestBody)

loResp = loHttp.PTextSb("PUT","https://api.easybill.de/rest/v1/positions/:id",loSbRequestBody,"utf-8","application/json",.F.,.F.)
if (loHttp.LastMethodSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loJson
    release loSbRequestBody
    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 loJson
    release loSbRequestBody
    release loSbResponseBody
    release loJResp
    return
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")
llStock_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")
llArchived = 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": ""
    }
  ]
}