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
}'
integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_SbResponseBody
integer li_RespStatusCode
oleobject loo_JsonResponse
string ls_ProcessingDate
string ls_PaymentIndicator
string ls_FormBundleNumber
loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
destroy loo_Rest
MessageBox("Error","Connecting to COM object failed")
return
end if
// URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("test-api.service.hmrc.gov.uk",li_Port,li_BTls,li_BAutoReconnect)
if li_Success <> 1 then
Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
return
end if
// See the Online Tool for Generating JSON Creation Code
loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")
loo_Json.UpdateString("periodKey","A001")
loo_Json.UpdateNumber("vatDueSales","105.50")
loo_Json.UpdateNumber("vatDueAcquisitions","-100.45")
loo_Json.UpdateNumber("totalVatDue","5.05")
loo_Json.UpdateNumber("vatReclaimedCurrPeriod","105.15")
loo_Json.UpdateNumber("netVatDue","100.10")
loo_Json.UpdateNumber("totalValueSalesExVAT","300")
loo_Json.UpdateNumber("totalValuePurchasesExVAT","300")
loo_Json.UpdateNumber("totalValueGoodsSuppliedExVAT","3000")
loo_Json.UpdateNumber("totalAcquisitionsExVAT","3000")
loo_Json.UpdateBool("finalised",1)
loo_Rest.AddHeader("Content-Type","application/json")
loo_Rest.AddHeader("Authorization","Bearer HMRC_ACCESS_TOKEN")
loo_Rest.AddHeader("Accept","application/vnd.hmrc.1.0+json")
loo_SbRequestBody = create oleobject
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")
loo_Json.EmitSb(loo_SbRequestBody)
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")
li_Success = loo_Rest.FullRequestSb("POST","/organisations/vat/MY_HMRC_VRN/returns",loo_SbRequestBody,loo_SbResponseBody)
if li_Success <> 1 then
Write-Debug loo_Rest.LastErrorText
destroy loo_Rest
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
return
end if
li_RespStatusCode = loo_Rest.ResponseStatusCode
if li_RespStatusCode >= 400 then
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
Write-Debug "Response Header:"
Write-Debug loo_Rest.ResponseHeader
Write-Debug "Response Body:"
Write-Debug loo_SbResponseBody.GetAsString()
destroy loo_Rest
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
return
end if
loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat_9_5_0.JsonObject")
loo_JsonResponse.LoadSb(loo_SbResponseBody)
// See the Online Tool for Generating JSON Parse Code
ls_ProcessingDate = loo_JsonResponse.StringOf("processingDate")
ls_PaymentIndicator = loo_JsonResponse.StringOf("paymentIndicator")
ls_FormBundleNumber = loo_JsonResponse.StringOf("formBundleNumber")
destroy loo_Rest
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JsonResponse
{
"processingDate": "2019-02-18T14:37:56.561Z",
"paymentIndicator": "BANK",
"formBundleNumber": "948551092841"
}