New: Cookbooks and AI ExplanationsStep-by-Step recipes to solve problems connected to Roadmaps and Cheat Sheets. Need more details? Use AI buttons for structured and simple explanations with concrete examples throughout the whole platform.Take a look
Why does your JSON endpoint sometimes answer back in HTML instead?
What you'll have at the end
The one request that proves it: the exact link, the Content-Type header it returned, and why it wasn't JSON
You need
A JSON endpoint that has answered back in HTML at least once, and a command-line HTTP client that can print the full response, status line and headers included, without automatically following a redirect.
Not covered
This does not cover fixing whichever cause you find, rewriting a redirect, adding a JSON error handler, changing a reverse proxy's own error pages, or catching a request sent with the wrong Accept header; it only covers naming which real cause produced the HTML you saw.
Leans on
Trace a blocked CORS preflight request back to its missing header
for when the browser's console shows a CORS or network error instead, before any status code or body comes back at all.
Catch an API that always answers 200 on failure
for when Content-Type already reads application/json and the 200 status itself is the lie hiding in the body.
Checked 18 Aug 2026
Part of the HTTP cookbook