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'
func chilkatTest() {
let rest = CkoRest()
var success: Bool
// URL: https://test-api.service.hmrc.gov.uk/organisations/vat/MY_HMRC_VRN/returns/A001
var bTls: Bool = true
var port: Int = 443
var bAutoReconnect: Bool = true
success = rest.Connect("test-api.service.hmrc.gov.uk", port: port, tls: bTls, autoReconnect: bAutoReconnect)
if success != true {
print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
print("\(rest.LastErrorText)")
return
}
rest.AddHeader("Authorization", value: "Bearer HMRC_ACCESS_TOKEN")
rest.AddHeader("Accept", value: "application/vnd.hmrc.1.0+json")
let sbResponseBody = CkoStringBuilder()
success = rest.FullRequestNoBodySb("GET", uriPath: "/organisations/vat/MY_HMRC_VRN/returns/A001", sb: sbResponseBody)
if success != true {
print("\(rest.LastErrorText)")
return
}
var respStatusCode: Int = rest.ResponseStatusCode.intValue
if respStatusCode >= 400 {
print("Response Status Code = \(respStatusCode)")
print("Response Header:")
print("\(rest.ResponseHeader)")
print("Response Body:")
print("\(sbResponseBody.GetAsString())")
return
}
let jsonResponse = CkoJsonObject()
jsonResponse.LoadSb(sbResponseBody)
// See the Online Tool for Generating JSON Parse Code
var periodKey: String?
var vatDueSales: String?
var vatDueAcquisitions: String?
var totalVatDue: String?
var vatReclaimedCurrPeriod: String?
var netVatDue: String?
var totalValueSalesExVAT: Int
var totalValuePurchasesExVAT: Int
var totalValueGoodsSuppliedExVAT: Int
var totalAcquisitionsExVAT: Int
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
}