WordPress JSON API returns only 404 errors

I’m brand new to WordPress and I would like to use the JSON API plugin.

So I put it in my plugin repository and I activated it but when I try to display the Json response by accessing the http://localhost/wordpress/wp-json/posts url I get a 404 error.

Read More

I’m probably missing something but according to the documentation it should be that simple. Any idea of what am I doing wrong?

Related posts

Leave a Reply

5 comments

  1. It is an mod_rewrite issue.

    Reason is one of these in your .htaccess:

    • not existing
    • wrong permissions
    • screwed up

    Try the htaccess documentation on WordPress for your .htaccess:

    ## BEGIN WordPress
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /
        RewriteRule ^index.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    
  2. Old question and answer, but for anyone coming here recently via search results (like me), /wp-json/posts should at least bring a JSON result (albeit still a 404 error), and /wp-json should list some available routes in JSON.

    If it doesn’t (e.g. it shows an Apache or other 404 error page), it’s probably a permalinks issue

  3. /wp-json/elementor/v1/globals – 404 error

    Just update the plugin if any update is available and deactivate it first and then re-activate it again. The problem will be solved.

    When we activate the Elementor plugin then this plugin creates some essential files for editing, so when we will re-activate it then it will re-create all essential files and our problem will be solved. Thanks

  4. It may depend on whether you have NGinx or Apache.
    On some hosts with Plesk if Nginx is used, Plesk does not create or re-create the .htaccess file, but for WP it must be present.
    If it’s not there, just recreate it with the standard WP settings https://wordpress.org/support/article/htaccess/ as mentioned in one of the previous answers.

    A workaround (insecure) is to create directories and files /wp-json/elementor/v1/globals with {} like Json standard, elementor will work the same, but I don’t recommend doing that.