t4mer@notebook

// til · http · 8 may 2026 · 1 min

TIL: Accept and Content-Type are different

Content-Type is what you are sending. Accept is what you are willing to receive. Mixing them is a classic API bug.

Content-Type describes the body you are sending. “This is JSON.”

Accept describes what you would like back. “Please reply with JSON.”

I have watched Laravel APIs return HTML error pages to API clients because Accept said nothing useful, and the framework (or the server) chose a web response. I have watched providers reject a body because Content-Type was application/json when they wanted a form.

Postman often sets both without making a fuss. Your HTTP client will not, unless you tell it.

Related: Postman vs Laravel, HTML instead of JSON.

Found something wrong?

These notes can be incomplete, or wrong in a different environment. Suggest a correction on GitHub or email me at me@t4mer.net.

// related