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
}'
load ./chilkat.dll
set rest [new_CkRest]
# URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns
set bTls 1
set port 443
set bAutoReconnect 1
set success [CkRest_Connect $rest "test-api.service.hmrc.gov.uk" $port $bTls $bAutoReconnect]
if {[expr $success != 1]} then {
puts "ConnectFailReason: [CkRest_get_ConnectFailReason $rest]"
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
exit
}
# See the Online Tool for Generating JSON Creation Code
set json [new_CkJsonObject]
CkJsonObject_UpdateString $json "periodKey" "A001"
CkJsonObject_UpdateNumber $json "vatDueSales" "105.50"
CkJsonObject_UpdateNumber $json "vatDueAcquisitions" "-100.45"
CkJsonObject_UpdateNumber $json "totalVatDue" "5.05"
CkJsonObject_UpdateNumber $json "vatReclaimedCurrPeriod" "105.15"
CkJsonObject_UpdateNumber $json "netVatDue" "100.10"
CkJsonObject_UpdateNumber $json "totalValueSalesExVAT" "300"
CkJsonObject_UpdateNumber $json "totalValuePurchasesExVAT" "300"
CkJsonObject_UpdateNumber $json "totalValueGoodsSuppliedExVAT" "3000"
CkJsonObject_UpdateNumber $json "totalAcquisitionsExVAT" "3000"
CkJsonObject_UpdateBool $json "finalised" 1
CkRest_AddHeader $rest "Content-Type" "application/json"
CkRest_AddHeader $rest "Authorization" "Bearer HMRC_ACCESS_TOKEN"
CkRest_AddHeader $rest "Accept" "application/vnd.hmrc.1.0+json"
set sbRequestBody [new_CkStringBuilder]
CkJsonObject_EmitSb $json $sbRequestBody
set sbResponseBody [new_CkStringBuilder]
set success [CkRest_FullRequestSb $rest "POST" "/organisations/vat/MY_HMRC_VRN/returns" $sbRequestBody $sbResponseBody]
if {[expr $success != 1]} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
exit
}
set respStatusCode [CkRest_get_ResponseStatusCode $rest]
if {[expr $respStatusCode >= 400]} then {
puts "Response Status Code = $respStatusCode"
puts "Response Header:"
puts [CkRest_responseHeader $rest]
puts "Response Body:"
puts [CkStringBuilder_getAsString $sbResponseBody]
delete_CkRest $rest
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
exit
}
set jsonResponse [new_CkJsonObject]
CkJsonObject_LoadSb $jsonResponse $sbResponseBody
# See the Online Tool for Generating JSON Parse Code
set processingDate [CkJsonObject_stringOf $jsonResponse "processingDate"]
set paymentIndicator [CkJsonObject_stringOf $jsonResponse "paymentIndicator"]
set formBundleNumber [CkJsonObject_stringOf $jsonResponse "formBundleNumber"]
delete_CkRest $rest
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jsonResponse
{
"processingDate": "2019-02-18T14:37:56.561Z",
"paymentIndicator": "BANK",
"formBundleNumber": "948551092841"
}