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
}'
#include <C_CkRest.h>
#include <C_CkJsonObject.h>
#include <C_CkStringBuilder.h>
void ChilkatSample(void)
{
HCkRest rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkJsonObject json;
HCkStringBuilder sbRequestBody;
HCkStringBuilder sbResponseBody;
int respStatusCode;
HCkJsonObject jsonResponse;
const char *processingDate;
const char *paymentIndicator;
const char *formBundleNumber;
rest = CkRest_Create();
// URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRest_Connect(rest,"test-api.service.hmrc.gov.uk",port,bTls,bAutoReconnect);
if (success != TRUE) {
printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
return;
}
// See the Online Tool for Generating JSON Creation Code
json = CkJsonObject_Create();
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",TRUE);
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");
sbRequestBody = CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilder_Create();
success = CkRest_FullRequestSb(rest,"POST","/organisations/vat/MY_HMRC_VRN/returns",sbRequestBody,sbResponseBody);
if (success != TRUE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRest_getResponseStatusCode(rest);
if (respStatusCode >= 400) {
printf("Response Status Code = %d\n",respStatusCode);
printf("Response Header:\n");
printf("%s\n",CkRest_responseHeader(rest));
printf("Response Body:\n");
printf("%s\n",CkStringBuilder_getAsString(sbResponseBody));
CkRest_Dispose(rest);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObject_Create();
CkJsonObject_LoadSb(jsonResponse,sbResponseBody);
// See the Online Tool for Generating JSON Parse Code
processingDate = CkJsonObject_stringOf(jsonResponse,"processingDate");
paymentIndicator = CkJsonObject_stringOf(jsonResponse,"paymentIndicator");
formBundleNumber = CkJsonObject_stringOf(jsonResponse,"formBundleNumber");
CkRest_Dispose(rest);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jsonResponse);
}
{
"processingDate": "2019-02-18T14:37:56.561Z",
"paymentIndicator": "BANK",
"formBundleNumber": "948551092841"
}