Back to Collection Items
LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp
* 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.
* {
* "type": "Summary",
* "format": "JSON",
* "queryParameters": {
* "dateFrom": "2020-10-01T21:00:28.451Z",
* "dateTo": "2020-12-30T21:00:28.451Z",
* "statuses": [
* "Valid",
* "Cancelled",
* "Rejected"
* ],
* "productsInternalCodes": [
* ],
* "receiverSenderId": "",
* "receiverSenderType": "0",
* "branchNumber": "",
* "itemCodes": [
* {
* "codeValue": "",
* "codeType": ""
* }
* ],
* "documentTypeNames": [
* ]
* }
* }
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("type","Summary")
loJson.UpdateString("format","JSON")
loJson.UpdateString("queryParameters.dateFrom","2020-10-01T21:00:28.451Z")
loJson.UpdateString("queryParameters.dateTo","2020-12-30T21:00:28.451Z")
loJson.UpdateString("queryParameters.statuses[0]","Valid")
loJson.UpdateString("queryParameters.statuses[1]","Cancelled")
loJson.UpdateString("queryParameters.statuses[2]","Rejected")
loJson.UpdateNewArray("queryParameters.productsInternalCodes")
loJson.UpdateString("queryParameters.receiverSenderId","")
loJson.UpdateString("queryParameters.receiverSenderType","0")
loJson.UpdateString("queryParameters.branchNumber","")
loJson.UpdateString("queryParameters.itemCodes[0].codeValue","")
loJson.UpdateString("queryParameters.itemCodes[0].codeType","")
loJson.UpdateNewArray("queryParameters.documentTypeNames")
* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"
loResp = loHttp.PostJson3("https://domain.com/api/v1/documentPackages/requests","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
? loHttp.LastErrorText
RELEASE loHttp
RELEASE loJson
CANCEL
ENDIF
? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loResp
RELEASE loHttp
RELEASE loJson
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"type": "Summary",
"format": "JSON",
"queryParameters": {
"dateFrom": "2020-10-01T21:00:28.451Z",
"dateTo": "2020-12-30T21:00:28.451Z",
"statuses": [
"Valid",
"Cancelled",
"Rejected"
],
"productsInternalCodes": [],
"receiverSenderId": "",
"receiverSenderType": "0",
"branchNumber": "",
"itemCodes": [
{
"codeValue": "",
"codeType": ""
}
],
"documentTypeNames": []
}
}'
https://domain.com/api/v1/documentPackages/requests
Postman Collection Item JSON
{
"name": "5. Request Document Package",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{generatedAccessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\r\n \"type\": \"Summary\",\r\n \"format\": \"JSON\",\r\n \"queryParameters\": {\r\n \"dateFrom\": \"2020-10-01T21:00:28.451Z\",\r\n \"dateTo\": \"2020-12-30T21:00:28.451Z\",\r\n \"statuses\": [\r\n \"Valid\",\r\n \"Cancelled\",\r\n \"Rejected\"\r\n ],\r\n \"productsInternalCodes\": [],\r\n \"receiverSenderId\": \"\",\r\n \"receiverSenderType\": \"0\",\r\n \"branchNumber\": \"\",\r\n \"itemCodes\": [\r\n {\r\n \"codeValue\": \"\",\r\n \"codeType\": \"\"\r\n }\r\n ],\r\n \"documentTypeNames\": []\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{apiBaseUrl}}/api/v1/documentPackages/requests",
"host": [
"{{apiBaseUrl}}"
],
"path": [
"api",
"v1",
"documentPackages",
"requests"
]
}
},
"response": [
]
}