This resource creates and returns a test user which is an individual. The caller can specify the required service enrolments in the request body. If no request body is supplied, the test user is created with no service enrolments.
curl -X POST https://test-api.service.hmrc.gov.uk/create-test-user/individuals \
-H 'Authorization: Bearer HMRC_SERVER_TOKEN' \
-H 'Accept: application/vnd.hmrc.1.0+json' \
-H 'Content-Type: application/json' \
-d '{
"serviceNames": [
"national-insurance",
"self-assessment",
"mtd-income-tax",
"customs-services",
"mtd-vat"
]
}'
func chilkatTest() {
let rest = CkoRest()
var success: Bool
// URL: https://test-api.service.hmrc.gov.uk/create-test-user/individuals
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
}
// See the Online Tool for Generating JSON Creation Code
let json = CkoJsonObject()
json.UpdateString("serviceNames[0]", value: "national-insurance")
json.UpdateString("serviceNames[1]", value: "self-assessment")
json.UpdateString("serviceNames[2]", value: "mtd-income-tax")
json.UpdateString("serviceNames[3]", value: "customs-services")
json.UpdateString("serviceNames[4]", value: "mtd-vat")
rest.AddHeader("Content-Type", value: "application/json")
rest.AddHeader("Authorization", value: "Bearer HMRC_SERVER_TOKEN")
rest.AddHeader("Accept", value: "application/vnd.hmrc.1.0+json")
let sbRequestBody = CkoStringBuilder()
json.EmitSb(sbRequestBody)
let sbResponseBody = CkoStringBuilder()
success = rest.FullRequestSb("POST", uriPath: "/create-test-user/individuals", requestBody: sbRequestBody, responseBody: 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 userId: String?
var password: String?
var userFullName: String?
var emailAddress: String?
var individualDetailsFirstName: String?
var individualDetailsLastName: String?
var individualDetailsDateOfBirth: String?
var individualDetailsAddressLine1: String?
var individualDetailsAddressLine2: String?
var individualDetailsAddressPostcode: String?
var saUtr: String?
var nino: String?
var mtdItId: String?
var vrn: String?
var vatRegistrationDate: String?
var eoriNumber: String?
userId = jsonResponse.StringOf("userId")
password = jsonResponse.StringOf("password")
userFullName = jsonResponse.StringOf("userFullName")
emailAddress = jsonResponse.StringOf("emailAddress")
individualDetailsFirstName = jsonResponse.StringOf("individualDetails.firstName")
individualDetailsLastName = jsonResponse.StringOf("individualDetails.lastName")
individualDetailsDateOfBirth = jsonResponse.StringOf("individualDetails.dateOfBirth")
individualDetailsAddressLine1 = jsonResponse.StringOf("individualDetails.address.line1")
individualDetailsAddressLine2 = jsonResponse.StringOf("individualDetails.address.line2")
individualDetailsAddressPostcode = jsonResponse.StringOf("individualDetails.address.postcode")
saUtr = jsonResponse.StringOf("saUtr")
nino = jsonResponse.StringOf("nino")
mtdItId = jsonResponse.StringOf("mtdItId")
vrn = jsonResponse.StringOf("vrn")
vatRegistrationDate = jsonResponse.StringOf("vatRegistrationDate")
eoriNumber = jsonResponse.StringOf("eoriNumber")
}
{
"userId": "218108528158",
"password": "yqf7dxFimlEp",
"userFullName": "Langley Paisley",
"emailAddress": "langley.paisley@example.com",
"individualDetails": {
"firstName": "Langley",
"lastName": "Paisley",
"dateOfBirth": "1960-06-01",
"address": {
"line1": "45 Springfield Rise",
"line2": "Verwood",
"postcode": "TS3 1PA"
}
},
"saUtr": "5000086129",
"nino": "OR430355A",
"mtdItId": "XAIT00000795145",
"vrn": "186141364",
"vatRegistrationDate": "2018-02-18",
"eoriNumber": "GB6569802992"
}