You probably have a browser extension installed that presents JSON as a nicely formatted, human readable HTML document.
Web service returns application/json but browser displays HTML
Question
My REST Web Service returns a JSON response using the following code:
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
header("Content-Type: application/json");
echo json_encode($languages,128);
However, when I test the service on my browser - it renders the JSON as HTML. If I inspect the source, I can see HTML tags and everything. What's causing this and how do I fix this?
Thanks.
P.S.: I'm using the Slim Framework, if that makes a difference.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow