Chilkat Online Tools

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

Dim http As New ChilkatHttp
Dim success As Long

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

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

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

Dim sbRequestBody As New ChilkatStringBuilder
success = json.EmitSb(sbRequestBody)

Dim resp As ChilkatHttpResponse
Set resp = http.PTextSb("PUT","https://api.easybill.de/rest/v1/positions/:id",sbRequestBody,"utf-8","application/json",0,0)
If (http.LastMethodSuccess = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Dim sbResponseBody As New ChilkatStringBuilder
success = resp.GetBodySb(sbResponseBody)

Dim jResp As New ChilkatJsonObject
success = jResp.LoadSb(sbResponseBody)
jResp.EmitCompact = 0

Debug.Print "Response Body:"
Debug.Print jResp.Emit()

Dim respStatusCode As Long
respStatusCode = resp.StatusCode
Debug.Print "Response Status Code = " & respStatusCode
If (respStatusCode >= 400) Then
    Debug.Print "Response Header:"
    Debug.Print resp.Header
    Debug.Print "Failed."

    Exit Sub
End If

' 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

Dim v_number As String
v_number = jResp.StringOf("number")
Dim description As String
description = jResp.StringOf("description")
Dim sale_price As String
sale_price = jResp.StringOf("sale_price")
Dim id As String
id = jResp.StringOf("id")
Dim v_type As String
v_type = jResp.StringOf("type")
Dim document_note As String
document_note = jResp.StringOf("document_note")
Dim note As String
note = jResp.StringOf("note")
Dim unit As String
unit = jResp.StringOf("unit")
Dim export_identifier As String
export_identifier = jResp.StringOf("export_identifier")
Dim v_NULL As String
v_NULL = jResp.StringOf("export_identifier_extended.NULL")
Dim NStb As String
NStb = jResp.StringOf("export_identifier_extended.nStb")
Dim NStbUstID As String
NStbUstID = jResp.StringOf("export_identifier_extended.nStbUstID")
Dim NStbNoneUstID As String
NStbNoneUstID = jResp.StringOf("export_identifier_extended.nStbNoneUstID")
Dim NStbIm As String
NStbIm = jResp.StringOf("export_identifier_extended.nStbIm")
Dim Revc As String
Revc = jResp.StringOf("export_identifier_extended.revc")
Dim IG As String
IG = jResp.StringOf("export_identifier_extended.IG")
Dim AL As String
AL = jResp.StringOf("export_identifier_extended.AL")
Dim SStfr As String
SStfr = jResp.StringOf("export_identifier_extended.sStfr")
Dim SmallBusiness As String
SmallBusiness = jResp.StringOf("export_identifier_extended.smallBusiness")
Dim login_id As String
login_id = jResp.StringOf("login_id")
Dim price_type As String
price_type = jResp.StringOf("price_type")
Dim vat_percent As Long
vat_percent = jResp.IntOf("vat_percent")
Dim sale_price2 As String
sale_price2 = jResp.StringOf("sale_price2")
Dim sale_price3 As String
sale_price3 = jResp.StringOf("sale_price3")
Dim sale_price4 As String
sale_price4 = jResp.StringOf("sale_price4")
Dim sale_price5 As String
sale_price5 = jResp.StringOf("sale_price5")
Dim sale_price6 As String
sale_price6 = jResp.StringOf("sale_price6")
Dim sale_price7 As String
sale_price7 = jResp.StringOf("sale_price7")
Dim sale_price8 As String
sale_price8 = jResp.StringOf("sale_price8")
Dim sale_price9 As String
sale_price9 = jResp.StringOf("sale_price9")
Dim sale_price10 As String
sale_price10 = jResp.StringOf("sale_price10")
Dim cost_price As String
cost_price = jResp.StringOf("cost_price")
Dim export_cost1 As String
export_cost1 = jResp.StringOf("export_cost1")
Dim export_cost2 As String
export_cost2 = jResp.StringOf("export_cost2")
Dim group_id As String
group_id = jResp.StringOf("group_id")
Dim stock As String
stock = jResp.StringOf("stock")
Dim stock_count As Long
stock_count = jResp.IntOf("stock_count")
Dim stock_limit_notify As Long
stock_limit_notify = jResp.BoolOf("stock_limit_notify")
Dim stock_limit_notify_frequency As String
stock_limit_notify_frequency = jResp.StringOf("stock_limit_notify_frequency")
Dim stock_limit As Long
stock_limit = jResp.IntOf("stock_limit")
Dim quantity As String
quantity = jResp.StringOf("quantity")
Dim archived As Long
archived = jResp.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": ""
    }
  ]
}