unicodeC / Egyptian eInvoicing SDK R1.5 / 5.1 Request Document Package as intermediary
Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkJsonObjectW json;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// 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": "Full",
// "format": "XML",
// "queryParameters": {
// "dateFrom": "2021-01-01T00:00:00.000Z",
// "dateTo": "2021-01-31T00:00:00.000Z",
// "statuses": [
// "Valid"
// ],
// "productsInternalCodes": [
// ],
// "receiverSenderType": "0",
// "documentTypeNames": [
// "C",
// "D",
// "I"
// ],
// "representedTaxpayerFilterType": "1",
// "representeeRin": "",
// "branchNumber": "",
// "itemCodes": [
// {
// "codeValue": "",
// "codeType": ""
// }
// ]
// }
// }
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"type",L"Full");
CkJsonObjectW_UpdateString(json,L"format",L"XML");
CkJsonObjectW_UpdateString(json,L"queryParameters.dateFrom",L"2021-01-01T00:00:00.000Z");
CkJsonObjectW_UpdateString(json,L"queryParameters.dateTo",L"2021-01-31T00:00:00.000Z");
CkJsonObjectW_UpdateString(json,L"queryParameters.statuses[0]",L"Valid");
CkJsonObjectW_UpdateNewArray(json,L"queryParameters.productsInternalCodes");
CkJsonObjectW_UpdateString(json,L"queryParameters.receiverSenderType",L"0");
CkJsonObjectW_UpdateString(json,L"queryParameters.documentTypeNames[0]",L"C");
CkJsonObjectW_UpdateString(json,L"queryParameters.documentTypeNames[1]",L"D");
CkJsonObjectW_UpdateString(json,L"queryParameters.documentTypeNames[2]",L"I");
CkJsonObjectW_UpdateString(json,L"queryParameters.representedTaxpayerFilterType",L"1");
CkJsonObjectW_UpdateString(json,L"queryParameters.representeeRin",L"");
CkJsonObjectW_UpdateString(json,L"queryParameters.branchNumber",L"");
CkJsonObjectW_UpdateString(json,L"queryParameters.itemCodes[0].codeValue",L"");
CkJsonObjectW_UpdateString(json,L"queryParameters.itemCodes[0].codeType",L"");
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
resp = CkHttpW_PostJson3(http,L"https://domain.com/api/v1/documentPackages/requests",L"application/json",json);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
return;
}
wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
CkJsonObjectW_Dispose(json);
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"type": "Full",
"format": "XML",
"queryParameters": {
"dateFrom": "2021-01-01T00:00:00.000Z",
"dateTo": "2021-01-31T00:00:00.000Z",
"statuses": [
"Valid"
],
"productsInternalCodes": [],
"receiverSenderType": "0",
"documentTypeNames": [
"C",
"D",
"I"
],
"representedTaxpayerFilterType": "1",
"representeeRin": "",
"branchNumber": "",
"itemCodes": [
{
"codeValue": "",
"codeType": ""
}
]
}
}'
https://domain.com/api/v1/documentPackages/requests
Postman Collection Item JSON
{
"name": "5.1 Request Document Package as intermediary",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{generatedAccessToken}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\r\n \"type\": \"Full\",\r\n \"format\": \"XML\",\r\n \"queryParameters\": {\r\n \"dateFrom\": \"2021-01-01T00:00:00.000Z\",\r\n \"dateTo\": \"2021-01-31T00:00:00.000Z\",\r\n \"statuses\": [\r\n \"Valid\"\r\n ],\r\n \"productsInternalCodes\": [],\r\n \"receiverSenderType\": \"0\",\r\n \"documentTypeNames\": [\r\n \"C\",\r\n \"D\",\r\n \"I\"\r\n ],\r\n \"representedTaxpayerFilterType\": \"1\",\r\n \"representeeRin\": \"\",\r\n \"branchNumber\": \"\",\r\n \"itemCodes\": [\r\n {\r\n \"codeValue\": \"\",\r\n \"codeType\": \"\"\r\n }\r\n ]\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{apiBaseUrl}}/api/v1/documentPackages/requests",
"host": [
"{{apiBaseUrl}}"
],
"path": [
"api",
"v1",
"documentPackages",
"requests"
]
}
},
"response": [
]
}