Back to Collection Items
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; 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
; }
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(json,"number","<string>")
CkJsonObject::ckUpdateString(json,"description","<string>")
CkJsonObject::ckUpdateString(json,"sale_price","<float>")
CkJsonObject::ckUpdateString(json,"id","<long>")
CkJsonObject::ckUpdateString(json,"type","PRODUCT")
CkJsonObject::ckUpdateString(json,"document_note","<string>")
CkJsonObject::ckUpdateNull(json,"note")
CkJsonObject::ckUpdateNull(json,"unit")
CkJsonObject::ckUpdateNull(json,"export_identifier")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.NULL")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.nStb")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.nStbUstID")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.nStbNoneUstID")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.nStbIm")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.revc")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.IG")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.AL")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.sStfr")
CkJsonObject::ckUpdateNull(json,"export_identifier_extended.smallBusiness")
CkJsonObject::ckUpdateString(json,"login_id","<long>")
CkJsonObject::ckUpdateString(json,"price_type","NETTO")
CkJsonObject::ckUpdateInt(json,"vat_percent",19)
CkJsonObject::ckUpdateNull(json,"sale_price2")
CkJsonObject::ckUpdateNull(json,"sale_price3")
CkJsonObject::ckUpdateNull(json,"sale_price4")
CkJsonObject::ckUpdateNull(json,"sale_price5")
CkJsonObject::ckUpdateNull(json,"sale_price6")
CkJsonObject::ckUpdateNull(json,"sale_price7")
CkJsonObject::ckUpdateNull(json,"sale_price8")
CkJsonObject::ckUpdateNull(json,"sale_price9")
CkJsonObject::ckUpdateNull(json,"sale_price10")
CkJsonObject::ckUpdateString(json,"cost_price","<float>")
CkJsonObject::ckUpdateNull(json,"export_cost1")
CkJsonObject::ckUpdateNull(json,"export_cost2")
CkJsonObject::ckUpdateString(json,"group_id","<long>")
CkJsonObject::ckUpdateString(json,"stock","NO")
CkJsonObject::ckUpdateInt(json,"stock_count",0)
CkJsonObject::ckUpdateBool(json,"stock_limit_notify",0)
CkJsonObject::ckUpdateString(json,"stock_limit_notify_frequency","ALWAYS")
CkJsonObject::ckUpdateInt(json,"stock_limit",0)
CkJsonObject::ckUpdateNull(json,"quantity")
CkJsonObject::ckUpdateBool(json,"archived",0)
CkHttp::ckSetRequestHeader(http,"Content-Type","application/json")
CkHttp::ckSetRequestHeader(http,"Authorization","{{apiKey}}")
CkHttp::ckSetRequestHeader(http,"Accept","application/json")
resp.i = CkHttp::ckPostJson3(http,"https://api.easybill.de/rest/v1/positions","application/json",json)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
ProcedureReturn
EndIf
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkHttpResponse::ckGetBodySb(resp,sbResponseBody)
jResp.i = CkJsonObject::ckCreate()
If jResp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckLoadSb(jResp,sbResponseBody)
CkJsonObject::setCkEmitCompact(jResp, 0)
Debug "Response Body:"
Debug CkJsonObject::ckEmit(jResp)
respStatusCode.i = CkHttpResponse::ckStatusCode(resp)
Debug "Response Status Code = " + Str(respStatusCode)
If respStatusCode >= 400
Debug "Response Header:"
Debug CkHttpResponse::ckHeader(resp)
Debug "Failed."
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndIf
CkHttpResponse::ckDispose(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
v_number.s = CkJsonObject::ckStringOf(jResp,"number")
description.s = CkJsonObject::ckStringOf(jResp,"description")
sale_price.s = CkJsonObject::ckStringOf(jResp,"sale_price")
id.s = CkJsonObject::ckStringOf(jResp,"id")
v_type.s = CkJsonObject::ckStringOf(jResp,"type")
document_note.s = CkJsonObject::ckStringOf(jResp,"document_note")
note.s = CkJsonObject::ckStringOf(jResp,"note")
unit.s = CkJsonObject::ckStringOf(jResp,"unit")
export_identifier.s = CkJsonObject::ckStringOf(jResp,"export_identifier")
v_NULL.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.NULL")
NStb.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.nStb")
NStbUstID.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.nStbUstID")
NStbNoneUstID.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.nStbNoneUstID")
NStbIm.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.nStbIm")
Revc.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.revc")
IG.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.IG")
AL.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.AL")
SStfr.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.sStfr")
SmallBusiness.s = CkJsonObject::ckStringOf(jResp,"export_identifier_extended.smallBusiness")
login_id.s = CkJsonObject::ckStringOf(jResp,"login_id")
price_type.s = CkJsonObject::ckStringOf(jResp,"price_type")
vat_percent.i = CkJsonObject::ckIntOf(jResp,"vat_percent")
sale_price2.s = CkJsonObject::ckStringOf(jResp,"sale_price2")
sale_price3.s = CkJsonObject::ckStringOf(jResp,"sale_price3")
sale_price4.s = CkJsonObject::ckStringOf(jResp,"sale_price4")
sale_price5.s = CkJsonObject::ckStringOf(jResp,"sale_price5")
sale_price6.s = CkJsonObject::ckStringOf(jResp,"sale_price6")
sale_price7.s = CkJsonObject::ckStringOf(jResp,"sale_price7")
sale_price8.s = CkJsonObject::ckStringOf(jResp,"sale_price8")
sale_price9.s = CkJsonObject::ckStringOf(jResp,"sale_price9")
sale_price10.s = CkJsonObject::ckStringOf(jResp,"sale_price10")
cost_price.s = CkJsonObject::ckStringOf(jResp,"cost_price")
export_cost1.s = CkJsonObject::ckStringOf(jResp,"export_cost1")
export_cost2.s = CkJsonObject::ckStringOf(jResp,"export_cost2")
group_id.s = CkJsonObject::ckStringOf(jResp,"group_id")
stock.s = CkJsonObject::ckStringOf(jResp,"stock")
stock_count.i = CkJsonObject::ckIntOf(jResp,"stock_count")
stock_limit_notify.i = CkJsonObject::ckBoolOf(jResp,"stock_limit_notify")
stock_limit_notify_frequency.s = CkJsonObject::ckStringOf(jResp,"stock_limit_notify_frequency")
stock_limit.i = CkJsonObject::ckIntOf(jResp,"stock_limit")
quantity.s = CkJsonObject::ckStringOf(jResp,"quantity")
archived.i = CkJsonObject::ckBoolOf(jResp,"archived")
CkHttp::ckDispose(http)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbResponseBody)
CkJsonObject::ckDispose(jResp)
ProcedureReturn
EndProcedure
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": ""
}
]
}