Chilkat Online Tools

PowerBuilder / easybill REST API / Create position

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_V_number
string ls_Description
string ls_Sale_price
string ls_Id
string ls_V_type
string ls_Document_note
string ls_Note
string ls_Unit
string ls_Export_identifier
string ls_V_NULL
string ls_NStb
string ls_NStbUstID
string ls_NStbNoneUstID
string ls_NStbIm
string ls_Revc
string ls_IG
string ls_AL
string ls_SStfr
string ls_SmallBusiness
string ls_Login_id
string ls_Price_type
integer li_Vat_percent
string ls_Sale_price2
string ls_Sale_price3
string ls_Sale_price4
string ls_Sale_price5
string ls_Sale_price6
string ls_Sale_price7
string ls_Sale_price8
string ls_Sale_price9
string ls_Sale_price10
string ls_Cost_price
string ls_Export_cost1
string ls_Export_cost2
string ls_Group_id
string ls_Stock
integer li_Stock_count
integer li_Stock_limit_notify
string ls_Stock_limit_notify_frequency
integer li_Stock_limit
string ls_Quantity
integer li_Archived

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")

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

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

loo_Resp = loo_Http.PostJson3("https://api.easybill.de/rest/v1/positions","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    return
end if

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_Json
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

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

ls_V_number = loo_JResp.StringOf("number")
ls_Description = loo_JResp.StringOf("description")
ls_Sale_price = loo_JResp.StringOf("sale_price")
ls_Id = loo_JResp.StringOf("id")
ls_V_type = loo_JResp.StringOf("type")
ls_Document_note = loo_JResp.StringOf("document_note")
ls_Note = loo_JResp.StringOf("note")
ls_Unit = loo_JResp.StringOf("unit")
ls_Export_identifier = loo_JResp.StringOf("export_identifier")
ls_V_NULL = loo_JResp.StringOf("export_identifier_extended.NULL")
ls_NStb = loo_JResp.StringOf("export_identifier_extended.nStb")
ls_NStbUstID = loo_JResp.StringOf("export_identifier_extended.nStbUstID")
ls_NStbNoneUstID = loo_JResp.StringOf("export_identifier_extended.nStbNoneUstID")
ls_NStbIm = loo_JResp.StringOf("export_identifier_extended.nStbIm")
ls_Revc = loo_JResp.StringOf("export_identifier_extended.revc")
ls_IG = loo_JResp.StringOf("export_identifier_extended.IG")
ls_AL = loo_JResp.StringOf("export_identifier_extended.AL")
ls_SStfr = loo_JResp.StringOf("export_identifier_extended.sStfr")
ls_SmallBusiness = loo_JResp.StringOf("export_identifier_extended.smallBusiness")
ls_Login_id = loo_JResp.StringOf("login_id")
ls_Price_type = loo_JResp.StringOf("price_type")
li_Vat_percent = loo_JResp.IntOf("vat_percent")
ls_Sale_price2 = loo_JResp.StringOf("sale_price2")
ls_Sale_price3 = loo_JResp.StringOf("sale_price3")
ls_Sale_price4 = loo_JResp.StringOf("sale_price4")
ls_Sale_price5 = loo_JResp.StringOf("sale_price5")
ls_Sale_price6 = loo_JResp.StringOf("sale_price6")
ls_Sale_price7 = loo_JResp.StringOf("sale_price7")
ls_Sale_price8 = loo_JResp.StringOf("sale_price8")
ls_Sale_price9 = loo_JResp.StringOf("sale_price9")
ls_Sale_price10 = loo_JResp.StringOf("sale_price10")
ls_Cost_price = loo_JResp.StringOf("cost_price")
ls_Export_cost1 = loo_JResp.StringOf("export_cost1")
ls_Export_cost2 = loo_JResp.StringOf("export_cost2")
ls_Group_id = loo_JResp.StringOf("group_id")
ls_Stock = loo_JResp.StringOf("stock")
li_Stock_count = loo_JResp.IntOf("stock_count")
li_Stock_limit_notify = loo_JResp.BoolOf("stock_limit_notify")
ls_Stock_limit_notify_frequency = loo_JResp.StringOf("stock_limit_notify_frequency")
li_Stock_limit = loo_JResp.IntOf("stock_limit")
ls_Quantity = loo_JResp.StringOf("quantity")
li_Archived = loo_JResp.BoolOf("archived")


destroy loo_Http
destroy loo_Json
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -X POST
	-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

Postman Collection Item JSON

{
  "name": "Create position",
  "request": {
    "method": "POST",
    "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",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "positions"
      ]
    }
  },
  "response": [
    {
      "name": "Successful operation",
      "originalRequest": {
        "method": "POST",
        "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",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "positions"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_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": "Too Many Requests",
      "originalRequest": {
        "method": "POST",
        "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",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "positions"
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}