How does HTTP content negotiation work (Accept vs Content-Type)?
β‘ Short Answer
Content-Type describes the body the sender is providing; Accept tells the server what the client wants back. The server picks a representation matching Accept (or returns 406 Not Acceptable). This also powers media-type API versioning.
βCoffee Chat Question
Concept Made Simple
βHow does HTTP content negotiation work (Accept vs Content-Type)?β
π§ Mind Map Answer
Remember It Faster
π₯What If?
Think Beyond the Expected
A client gets 415 Unsupported Media Type on a POST β what's wrong?
The client sent a body in a format the endpoint doesn't accept (or omitted/typo'd Content-Type, e.g. sending JSON without Content-Type: application/json). Set the correct Content-Type so the server picks the right parser.
πReal World
Content negotiation underlies returning JSON vs CSV from the same endpoint and media-type versioning (application/vnd.myapi.v2+json); 415/406 errors are everyday API debugging.
π―Interviewer's Expectation
Keywords they're listening for:
β οΈCommon Mistakes
- βOmitting Content-Type on JSON POSTs
- βConfusing Accept with Content-Type
- βReturning 400 where 415/406 fits
β Best Practices
- βAlways set Content-Type on requests with a body
- βUse Accept for negotiation
- βReturn precise 406/415 codes
πFollow-up Questions
- 1406 vs 415 β which is which?
- 2How does media-type versioning use Accept?
- 3How would you serve both JSON and CSV from one endpoint?
π§©Related Technologies
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly β AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: HTTP Methods (REST APIs) Interview question: "How does HTTP content negotiation work (Accept vs Content-Type)?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
β Featured Products
Support our platform by exploring our recommended products.
As an Amazon affiliate, purchases through these links may earn us a small commission β at no extra cost to you. It helps keep Full Stack Interview Guru free.