All jobs / Backend developer / API Development
Backend developer interview question · 1–3 years
The interviewer asks: “How should API errors look to clients?” Strongest answer?
The strongest answer
A stable shape — Problem Details (RFC 9457) or equivalent: type, title, status, a machine code, correlation id. Don't change field names per endpoint. Don't leak stacks.
Why it works
Exactly. Frontends and other services bind to a contract. A correlation id lets support grep logs without a stack in the browser.
What a good answer covers
- One error envelope, stable fields.
- Machine code + correlation id.
- No stacks on the wire.
- Don't parse English; don't hide errors in 200.
Answers that fall short
- Close, but not the strongest: Whatever exception.ToString() produces, so developers see the truth.
ToString() is a stack trace. That's for logs. Clients need a code they can switch on. - Weak: A different JSON shape per team so each service can evolve.
Per-team shapes mean every client is a special case. One error envelope in the org. - Red flag: HTTP 200 with a string message; clients parse English.
English is not a protocol (and it breaks the moment you translate). Use codes; put human text in title/detail.
Who gets asked this
More API Development questions
- The interviewer asks: “How do you version a public JSON API?” Strongest answer?
- When would you pick gRPC over a JSON REST API, and what do you give up?
- Your OpenAPI document lists every path and method and nothing else. A partner team says integrating still…
- The interviewer asks: “You're building an internal platform API other teams will live on. What changes?”…
- The interviewer asks: “When do you use GET versus POST?” Strongest answer?
- The interviewer asks: “What's the difference between HTTP 401 and 403?” Strongest answer?
- The interviewer asks: “When is 404 the right status, and when is 400?” Strongest answer?
- The interviewer sketches /getOrder and /doDeleteUser. Strongest design?