Reading HTTP Error Messages in API Responses
5 exercises — read a realistic HTTP 422 API error response with a structured JSON body. Understand status codes, request IDs, structured error details, and why design choices matter for developers.
Reading API error responses
- Status code first → 4xx = client error (you sent something wrong); 5xx = server error (their fault)
- error.code → a machine-readable string identifying the error type
- error.message → human-readable summary
- error.details → field-level breakdown of what exactly failed
- request_id → always save this — you need it if you contact API support
0 / 5 completed
1 / 5
API Error Response — HTTP 422
{ex.passage} What does HTTP status code 422 Unprocessable Entity mean in the context of this API response?
422 = syntactically valid request, but semantically wrong — business validation failed:
The response body confirms this: "The request body contains invalid or missing fields." The JSON was parsed successfully (no syntax error), but the field values and presence don't meet the API's requirements.
HTTP status code anatomy:
A developer receiving a 400 should fix how the request is formed. A developer receiving a 422 should fix the field values. These require different debugging approaches.
The response body confirms this: "The request body contains invalid or missing fields." The JSON was parsed successfully (no syntax error), but the field values and presence don't meet the API's requirements.
HTTP status code anatomy:
- 2xx → Success (200 OK, 201 Created)
- 4xx → Client error — the request has a problem
- 5xx → Server error — the server failed to handle a valid request
- 400 Bad Request → the request itself is malformed. Typical causes: invalid JSON, wrong Content-Type, missing required HTTP headers.
- 422 Unprocessable Entity → the request was received and parsed fine, but the data inside doesn't pass validation. Typical causes: wrong email format, missing required field, value out of range.
A developer receiving a 400 should fix how the request is formed. A developer receiving a 422 should fix the field values. These require different debugging approaches.