Retrieve VAT payments
curl -X GET https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/payments?from=2018-06-25&to=2019-02-17 \
-H 'Authorization: Bearer HMRC_ACCESS_TOKEN' \
-H 'Accept: application/vnd.hmrc.1.0+json'
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Boolean iBTls
Integer iPort
Boolean iBAutoReconnect
Variant vSbResponseBody
Handle hoSbResponseBody
Integer iRespStatusCode
Handle hoJsonResponse
Integer i
Integer iCount_i
String sAmount
String sReceived
String sTemp1
Integer iTemp1
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
// URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/payments?from=2018-06-25&to=2019-02-17
Move True To iBTls
Move 443 To iPort
Move True To iBAutoReconnect
Get ComConnect Of hoRest "test-api.service.hmrc.gov.uk" iPort iBTls iBAutoReconnect To iSuccess
If (iSuccess <> True) Begin
Get ComConnectFailReason Of hoRest To iTemp1
Showln "ConnectFailReason: " iTemp1
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComAddHeader Of hoRest "Authorization" "Bearer HMRC_ACCESS_TOKEN" To iSuccess
Get ComAddHeader Of hoRest "Accept" "application/vnd.hmrc.1.0+json" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComFullRequestNoBodySb Of hoRest "GET" "/organisations/vat/MY_HMRC_VRN/payments?from=2018-06-25&to=2019-02-17" vSbResponseBody To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComResponseStatusCode Of hoRest To iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Status Code = " iRespStatusCode
Showln "Response Header:"
Get ComResponseHeader Of hoRest To sTemp1
Showln sTemp1
Showln "Response Body:"
Get ComGetAsString Of hoSbResponseBody To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse
If (Not(IsComObjectCreated(hoJsonResponse))) Begin
Send CreateComObject of hoJsonResponse
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJsonResponse vSbResponseBody To iSuccess
// See the Online Tool for Generating JSON Parse Code
Move 0 To i
Get ComSizeOfArray Of hoJsonResponse "payments" To iCount_i
While (i < iCount_i)
Set ComI Of hoJsonResponse To i
Get ComStringOf Of hoJsonResponse "payments[i].amount" To sAmount
Get ComStringOf Of hoJsonResponse "payments[i].received" To sReceived
Move i + 1 To i
Loop
End_Procedure
{
"payments": [
{
"amount": 100.05,
"received": "2018-04-06"
}
]
}