Chilkat Online Tools

autoit / Egyptian eInvoicing SDK R1.5 / 5.1 Request Document Package as intermediary

Back to Collection Items

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

$oHttp = ObjCreate("Chilkat_9_5_0.Http")
Local $bSuccess

; 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": ""
;       }
;     ]
;   }
; }

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("type","Full")
$oJson.UpdateString("format","XML")
$oJson.UpdateString("queryParameters.dateFrom","2021-01-01T00:00:00.000Z")
$oJson.UpdateString("queryParameters.dateTo","2021-01-31T00:00:00.000Z")
$oJson.UpdateString("queryParameters.statuses[0]","Valid")
$oJson.UpdateNewArray("queryParameters.productsInternalCodes")
$oJson.UpdateString("queryParameters.receiverSenderType","0")
$oJson.UpdateString("queryParameters.documentTypeNames[0]","C")
$oJson.UpdateString("queryParameters.documentTypeNames[1]","D")
$oJson.UpdateString("queryParameters.documentTypeNames[2]","I")
$oJson.UpdateString("queryParameters.representedTaxpayerFilterType","1")
$oJson.UpdateString("queryParameters.representeeRin","")
$oJson.UpdateString("queryParameters.branchNumber","")
$oJson.UpdateString("queryParameters.itemCodes[0].codeValue","")
$oJson.UpdateString("queryParameters.itemCodes[0].codeType","")

; Adds the "Authorization: Bearer <access_token>" header.
$oHttp.AuthToken = "<access_token>"

Local $oResp = $oHttp.PostJson3("https://domain.com/api/v1/documentPackages/requests","application/json",$oJson)
If ($oHttp.LastMethodSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite($oResp.StatusCode & @CRLF)
ConsoleWrite($oResp.BodyStr & @CRLF)

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": [
  ]
}