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
}'
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Boolean iBTls
Integer iPort
Boolean iBAutoReconnect
Handle hoJson
Variant vSbRequestBody
Handle hoSbRequestBody
Variant vSbResponseBody
Handle hoSbResponseBody
Integer iRespStatusCode
Response Handle hoJsonResponse
String sProcessingDate
String sPaymentIndicator
String sFormBundleNumber
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/returns
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
// See the Online Tool for Generating JSON Creation Code
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "periodKey" "A001" To iSuccess
Get ComUpdateNumber Of hoJson "vatDueSales" "105.50" To iSuccess
Get ComUpdateNumber Of hoJson "vatDueAcquisitions" "-100.45" To iSuccess
Get ComUpdateNumber Of hoJson "totalVatDue" "5.05" To iSuccess
Get ComUpdateNumber Of hoJson "vatReclaimedCurrPeriod" "105.15" To iSuccess
Get ComUpdateNumber Of hoJson "netVatDue" "100.10" To iSuccess
Get ComUpdateNumber Of hoJson "totalValueSalesExVAT" "300" To iSuccess
Get ComUpdateNumber Of hoJson "totalValuePurchasesExVAT" "300" To iSuccess
Get ComUpdateNumber Of hoJson "totalValueGoodsSuppliedExVAT" "3000" To iSuccess
Get ComUpdateNumber Of hoJson "totalAcquisitionsExVAT" "3000" To iSuccess
Get ComUpdateBool Of hoJson "finalised" True To iSuccess
Get ComAddHeader Of hoRest "Content-Type" "application/json" To iSuccess
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 hoSbRequestBody
If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
Send CreateComObject of hoSbRequestBody
End
Get pvComObject of hoSbRequestBody to vSbRequestBody
Get ComEmitSb Of hoJson vSbRequestBody To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbRequestBody to vSbRequestBody
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComFullRequestSb Of hoRest "POST" "/organisations/vat/MY_HMRC_VRN/returns" vSbRequestBody 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
Get ComStringOf Of hoJsonResponse "processingDate" To sProcessingDate
Get ComStringOf Of hoJsonResponse "paymentIndicator" To sPaymentIndicator
Get ComStringOf Of hoJsonResponse "formBundleNumber" To sFormBundleNumber
End_Procedure
{
"processingDate": "2019-02-18T14:37:56.561Z",
"paymentIndicator": "BANK",
"formBundleNumber": "948551092841"
}