WordPress JSON API returns normal site page in html. How do I get it to give me JSON?

For example, entering http://mywordpresswebsite.example.com/?json=1 into the browser loads the main site html, the same as omitting the json querystring variable: http://mywordpresswebsite.example.com/

The JSON API is activated. I have tried reactivating and deactivating, checking .htaccess file settings, and deactivating all other plugins. None of those have made much difference so far.

3 Answers
3

I’m likely doing it wrong, but when I form my requests for a WordPress installation at http://www.example.com/ like this:

http://www.example.com/index.php?rest_route=/my/rest/route/here

I end up getting proper responses back.

I had a heck of a time figuring this out and ended up grokking a URL formatted like that in the HTML returned to me. I was expecting to make requests as http://www.example.com/wp_json/wp/v2/my/rest/route/here , but I only got HTML responses.

Leave a Comment