Submit VAT return for period
curl -X POST https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns \
-H 'Authorization: Bearer HMRC_ACCESS_TOKEN' \
-H 'Accept: application/vnd.hmrc.1.0+json' \
-H 'Content-Type: application/json' \
-d '{
"periodKey": "A001",
"vatDueSales": 105.50,
"vatDueAcquisitions": -100.45,
"totalVatDue": 5.05,
"vatReclaimedCurrPeriod": 105.15,
"netVatDue": 100.10,
"totalValueSalesExVAT": 300,
"totalValuePurchasesExVAT": 300,
"totalValueGoodsSuppliedExVAT": 3000,
"totalAcquisitionsExVAT": 3000,
"finalised": true
}'
LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJsonResponse
LOCAL lcProcessingDate
LOCAL lcPaymentIndicator
LOCAL lcFormBundleNumber
loRest = CreateObject('Chilkat_9_5_0.Rest')
* URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns
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
* See the Online Tool for Generating JSON Creation Code
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("periodKey","A001")
loJson.UpdateNumber("vatDueSales","105.50")
loJson.UpdateNumber("vatDueAcquisitions","-100.45")
loJson.UpdateNumber("totalVatDue","5.05")
loJson.UpdateNumber("vatReclaimedCurrPeriod","105.15")
loJson.UpdateNumber("netVatDue","100.10")
loJson.UpdateNumber("totalValueSalesExVAT","300")
loJson.UpdateNumber("totalValuePurchasesExVAT","300")
loJson.UpdateNumber("totalValueGoodsSuppliedExVAT","3000")
loJson.UpdateNumber("totalAcquisitionsExVAT","3000")
loJson.UpdateBool("finalised",1)
loRest.AddHeader("Content-Type","application/json")
loRest.AddHeader("Authorization","Bearer HMRC_ACCESS_TOKEN")
loRest.AddHeader("Accept","application/vnd.hmrc.1.0+json")
loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/organisations/vat/MY_HMRC_VRN/returns",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loJson
RELEASE loSbRequestBody
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 loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)
* See the Online Tool for Generating JSON Parse Code
lcProcessingDate = loJsonResponse.StringOf("processingDate")
lcPaymentIndicator = loJsonResponse.StringOf("paymentIndicator")
lcFormBundleNumber = loJsonResponse.StringOf("formBundleNumber")
RELEASE loRest
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJsonResponse
{
"processingDate": "2019-02-18T14:37:56.561Z",
"paymentIndicator": "BANK",
"formBundleNumber": "948551092841"
}