unicodeCpp / Egyptian eInvoicing SDK R1.5 / 5.1 Request Document Package as intermediary
Back to Collection Items
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
bool success;
// 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": ""
// }
// ]
// }
// }
CkJsonObjectW json;
json.UpdateString(L"type",L"Full");
json.UpdateString(L"format",L"XML");
json.UpdateString(L"queryParameters.dateFrom",L"2021-01-01T00:00:00.000Z");
json.UpdateString(L"queryParameters.dateTo",L"2021-01-31T00:00:00.000Z");
json.UpdateString(L"queryParameters.statuses[0]",L"Valid");
json.UpdateNewArray(L"queryParameters.productsInternalCodes");
json.UpdateString(L"queryParameters.receiverSenderType",L"0");
json.UpdateString(L"queryParameters.documentTypeNames[0]",L"C");
json.UpdateString(L"queryParameters.documentTypeNames[1]",L"D");
json.UpdateString(L"queryParameters.documentTypeNames[2]",L"I");
json.UpdateString(L"queryParameters.representedTaxpayerFilterType",L"1");
json.UpdateString(L"queryParameters.representeeRin",L"");
json.UpdateString(L"queryParameters.branchNumber",L"");
json.UpdateString(L"queryParameters.itemCodes[0].codeValue",L"");
json.UpdateString(L"queryParameters.itemCodes[0].codeType",L"");
// Adds the "Authorization: Bearer <access_token>" header.
http.put_AuthToken(L"<access_token>");
CkHttpResponseW *resp = http.PostJson3(L"https://domain.com/api/v1/documentPackages/requests",L"application/json",json);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"%d\n",resp->get_StatusCode());
wprintf(L"%s\n",resp->bodyStr());
delete resp;
}
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": [
]
}