As asked
What is the correct HTTP status code for each of these: a resource that does not exist, a successful resource creation, a request with a valid format but invalid business logic, and a server error whose cause is unknown?
Sample answer outline
404 for resource not found, 201 for successful creation (with Location header), 422 Unprocessable Entity for syntactically valid but semantically invalid requests (some teams use 400; either is defensible with a reason), and 500 for unknown server error. Strong candidates distinguish 400 (bad input format) from 422 (valid format but fails business validation), and know that 200 on a creation is technically wrong even if widely used.
Expect these follow-ups
- When would you use 409 Conflict versus 422 Unprocessable Entity?