How does HTTP content negotiation work (Accept vs Content-Type)?
Reviewed by Gurusankar M.
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.
On this page
Concept Made Simple
Coffee Chat Question
“How does HTTP content negotiation work (Accept vs Content-Type)?”
Remember It Faster
Mind Map Answer
- Content-Type
- format of THIS request/response body
- Accept
- formats the client will accept back
- 406
- server can't meet the Accept
- 415
- server can't read the Content-Type
Think Beyond the Expected
What If?
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:
- Content-Type = body format
- Accept = desired response
- 406 vs 415
- media-type versioning
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
- 406 vs 415 — which is which?
- How does media-type versioning use Accept?
- How would you serve both JSON and CSV from one endpoint?
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?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair