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.
I'm probably missing something but according to the documentation it should be that simple. Any idea of what am I doing wrong?
You fix this by opening the listen step in your VSM file, and changing the base path in there, so you don't get a 404 error. You could change that to "/api/" so any api requests are dealt-with, or "/api/retrieveId/" so only retrieveId messages are dealt-with, or "/" so all requests are dealt-with.
The WordPress REST API provides an interface for applications to interact with your WordPress site by sending and receiving data as JSON (JavaScript Object Notation) objects.
It is an mod_rewrite issue.
Reason is one of these in your .htaccess:
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
You have the wrong address. According to the documentation, the following are valid links:
Implicit mode examples:
Explicit mode examples:
With user-friendly permalinks configured:
Source: https://wordpress.org/plugins/json-api/other_notes/
So in your case you should use http://localhost/wordpress/api/get_recent_posts/
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With