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'
#import <CkoRest.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>
CkoRest *rest = [[CkoRest alloc] init];
BOOL success;
// URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns/A001
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"test-api.service.hmrc.gov.uk" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
NSLog(@"%@",rest.LastErrorText);
return;
}
[rest AddHeader: @"Authorization" value: @"Bearer HMRC_ACCESS_TOKEN"];
[rest AddHeader: @"Accept" value: @"application/vnd.hmrc.1.0+json"];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestNoBodySb: @"GET" uriPath: @"/organisations/vat/MY_HMRC_VRN/returns/A001" sb: sbResponseBody];
if (success != YES) {
NSLog(@"%@",rest.LastErrorText);
return;
}
int respStatusCode = [rest.ResponseStatusCode intValue];
if (respStatusCode >= 400) {
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
NSLog(@"%@",@"Response Header:");
NSLog(@"%@",rest.ResponseHeader);
NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[sbResponseBody GetAsString]);
return;
}
CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse LoadSb: sbResponseBody];
// See the Online Tool for Generating JSON Parse Code
NSString *periodKey = 0;
NSString *vatDueSales = 0;
NSString *vatDueAcquisitions = 0;
NSString *totalVatDue = 0;
NSString *vatReclaimedCurrPeriod = 0;
NSString *netVatDue = 0;
int totalValueSalesExVAT;
int totalValuePurchasesExVAT;
int totalValueGoodsSuppliedExVAT;
int totalAcquisitionsExVAT;
periodKey = [jsonResponse StringOf: @"periodKey"];
vatDueSales = [jsonResponse StringOf: @"vatDueSales"];
vatDueAcquisitions = [jsonResponse StringOf: @"vatDueAcquisitions"];
totalVatDue = [jsonResponse StringOf: @"totalVatDue"];
vatReclaimedCurrPeriod = [jsonResponse StringOf: @"vatReclaimedCurrPeriod"];
netVatDue = [jsonResponse StringOf: @"netVatDue"];
totalValueSalesExVAT = [[jsonResponse IntOf: @"totalValueSalesExVAT"] intValue];
totalValuePurchasesExVAT = [[jsonResponse IntOf: @"totalValuePurchasesExVAT"] intValue];
totalValueGoodsSuppliedExVAT = [[jsonResponse IntOf: @"totalValueGoodsSuppliedExVAT"] intValue];
totalAcquisitionsExVAT = [[jsonResponse IntOf: @"totalAcquisitionsExVAT"] intValue];
{
"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
}