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'
LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJsonResponse
LOCAL i
LOCAL lnCount_i
LOCAL lcAmount
LOCAL lcReceived
loRest = CreateObject('Chilkat_9_5_0.Rest')
* URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/payments?from=2018-06-25&to=2019-02-17
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("test-api.service.hmrc.gov.uk",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
CANCEL
ENDIF
loRest.AddHeader("Authorization","Bearer HMRC_ACCESS_TOKEN")
loRest.AddHeader("Accept","application/vnd.hmrc.1.0+json")
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/organisations/vat/MY_HMRC_VRN/payments?from=2018-06-25&to=2019-02-17",loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loSbResponseBody
CANCEL
ENDIF
lnRespStatusCode = loRest.ResponseStatusCode
IF (lnRespStatusCode >= 400) THEN
? "Response Status Code = " + STR(lnRespStatusCode)
? "Response Header:"
? loRest.ResponseHeader
? "Response Body:"
? loSbResponseBody.GetAsString()
RELEASE loRest
RELEASE loSbResponseBody
CANCEL
ENDIF
loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)
* See the Online Tool for Generating JSON Parse Code
i = 0
lnCount_i = loJsonResponse.SizeOfArray("payments")
DO WHILE i < lnCount_i
loJsonResponse.I = i
lcAmount = loJsonResponse.StringOf("payments[i].amount")
lcReceived = loJsonResponse.StringOf("payments[i].received")
i = i + 1
ENDDO
RELEASE loRest
RELEASE loSbResponseBody
RELEASE loJsonResponse
{
"payments": [
{
"amount": 100.05,
"received": "2018-04-06"
}
]
}