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 <CkRestW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
CkRestW rest;
bool success;
// URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns/A001
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect(L"test-api.service.hmrc.gov.uk",port,bTls,bAutoReconnect);
if (success != true) {
wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
wprintf(L"%s\n",rest.lastErrorText());
return;
}
rest.AddHeader(L"Authorization",L"Bearer HMRC_ACCESS_TOKEN");
rest.AddHeader(L"Accept",L"application/vnd.hmrc.1.0+json");
CkStringBuilderW sbResponseBody;
success = rest.FullRequestNoBodySb(L"GET",L"/organisations/vat/MY_HMRC_VRN/returns/A001",sbResponseBody);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",rest.responseHeader());
wprintf(L"Response Body:\n");
wprintf(L"%s\n",sbResponseBody.getAsString());
return;
}
CkJsonObjectW jsonResponse;
jsonResponse.LoadSb(sbResponseBody);
// See the Online Tool for Generating JSON Parse Code
const wchar_t *periodKey = 0;
const wchar_t *vatDueSales = 0;
const wchar_t *vatDueAcquisitions = 0;
const wchar_t *totalVatDue = 0;
const wchar_t *vatReclaimedCurrPeriod = 0;
const wchar_t *netVatDue = 0;
int totalValueSalesExVAT;
int totalValuePurchasesExVAT;
int totalValueGoodsSuppliedExVAT;
int totalAcquisitionsExVAT;
periodKey = jsonResponse.stringOf(L"periodKey");
vatDueSales = jsonResponse.stringOf(L"vatDueSales");
vatDueAcquisitions = jsonResponse.stringOf(L"vatDueAcquisitions");
totalVatDue = jsonResponse.stringOf(L"totalVatDue");
vatReclaimedCurrPeriod = jsonResponse.stringOf(L"vatReclaimedCurrPeriod");
netVatDue = jsonResponse.stringOf(L"netVatDue");
totalValueSalesExVAT = jsonResponse.IntOf(L"totalValueSalesExVAT");
totalValuePurchasesExVAT = jsonResponse.IntOf(L"totalValuePurchasesExVAT");
totalValueGoodsSuppliedExVAT = jsonResponse.IntOf(L"totalValueGoodsSuppliedExVAT");
totalAcquisitionsExVAT = jsonResponse.IntOf(L"totalAcquisitionsExVAT");
}
{
"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
}