Validate a user API response
- API testing
- beginner
- 6 min
- 2 questions
API tests fail most often because testers check only the status code. Here you read a real-looking JSON response and decide which checks actually prove the endpoint works.
Skills practised: JSON reading, Contract checks, Data type validation
Worked example
If the contract says id is a number, a response with "id": "42" passes a status check but breaks every client that does maths with the id.
{ "id": "42", "email": "a@b.co" }Question 1
Contract: id (integer), email (string), roles (array, never empty), createdAt (ISO date). Which fields in this response break the contract?
{
"id": 101,
"email": "riya@example.com",
"roles": [],
"createdAt": "02/11/2026"
}Question 2
In JavaScript, what does typeof return for the roles value above? (one word)
0/2 answered
