Retrieve a previously submitted VAT return. This example retrieves the VAT return with period key "A001".
curl -X GET https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns/A001 \
-H 'Authorization: Bearer HMRC_ACCESS_TOKEN' \
-H 'Accept: application/vnd.hmrc.1.0+json'
#include <C_CkRestW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jsonResponse;
const wchar_t *periodKey;
const wchar_t *vatDueSales;
const wchar_t *vatDueAcquisitions;
const wchar_t *totalVatDue;
const wchar_t *vatReclaimedCurrPeriod;
const wchar_t *netVatDue;
int totalValueSalesExVAT;
int totalValuePurchasesExVAT;
int totalValueGoodsSuppliedExVAT;
int totalAcquisitionsExVAT;
rest = CkRestW_Create();
// URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns/A001
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRestW_Connect(rest,L"test-api.service.hmrc.gov.uk",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
CkRestW_AddHeader(rest,L"Authorization",L"Bearer HMRC_ACCESS_TOKEN");
CkRestW_AddHeader(rest,L"Accept",L"application/vnd.hmrc.1.0+json");
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/organisations/vat/MY_HMRC_VRN/returns/A001",sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
// See the Online Tool for Generating JSON Parse Code
periodKey = CkJsonObjectW_stringOf(jsonResponse,L"periodKey");
vatDueSales = CkJsonObjectW_stringOf(jsonResponse,L"vatDueSales");
vatDueAcquisitions = CkJsonObjectW_stringOf(jsonResponse,L"vatDueAcquisitions");
totalVatDue = CkJsonObjectW_stringOf(jsonResponse,L"totalVatDue");
vatReclaimedCurrPeriod = CkJsonObjectW_stringOf(jsonResponse,L"vatReclaimedCurrPeriod");
netVatDue = CkJsonObjectW_stringOf(jsonResponse,L"netVatDue");
totalValueSalesExVAT = CkJsonObjectW_IntOf(jsonResponse,L"totalValueSalesExVAT");
totalValuePurchasesExVAT = CkJsonObjectW_IntOf(jsonResponse,L"totalValuePurchasesExVAT");
totalValueGoodsSuppliedExVAT = CkJsonObjectW_IntOf(jsonResponse,L"totalValueGoodsSuppliedExVAT");
totalAcquisitionsExVAT = CkJsonObjectW_IntOf(jsonResponse,L"totalAcquisitionsExVAT");
CkRestW_Dispose(rest);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jsonResponse);
}
{
"periodKey": "A001",
"vatDueSales": 105.5,
"vatDueAcquisitions": -100.45,
"totalVatDue": 5.05,
"vatReclaimedCurrPeriod": 105.15,
"netVatDue": 100.1,
"totalValueSalesExVAT": 300,
"totalValuePurchasesExVAT": 300,
"totalValueGoodsSuppliedExVAT": 3000,
"totalAcquisitionsExVAT": 3000
}