I just installed and activated the latest version of the WP REST API plugin. However, when I attempt to access a REST endpoint, I end up with the Apache 404 page.

$ curl -i 'http://example.com/wp-json/wp/v2/posts/1'
HTTP/1.1 404 Not Found
Date: Wed, 20 Jul 2016 01:23:25 GMT
Server: Apache/2.4.18 (Unix) PHP/5.6.23
Content-Length: 219
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /wp-json/wp/v2/posts/1 was not found on this server.</p>
</body></html>

That is — WordPress itself is never invoked. I’d expect the above request to throw an error of some sort (since I’m attempting to connect unauthenticated). However, my WordPress system is being bypassed entirely.

I’m an experienced PHP developer here, but I only ever dip in and out of WordPress dev so apologies in advance for a question that likely has an obvious answer. This bit of cryptic-to-me text from the installation instructions seems like it may be relevant

For full-flavored API support, you’ll need to be using pretty permalinks to use the plugin, as it uses custom rewrite rules to power the API.

but not being familiar with WordPress’ routing system (or equivalent), I’m not sure what my next steps should be in debugging this problem.

1 Answer
1

Try changing your permalinks structure. Within the dashboard go to Settings > Permalinks and select the Post Name structure. When this is done click Save Changes.

If Post Name is already selected, it might be worth clicking save changes again to reset the permalinks.

Update: Per the comments below, WordPress does not, out of the box, ship with a .htaccess file for its frontend application. When you change permalink settings, WordPress will attempt to write out a .htaccess file for your . If it doesn’t have permission, the UI will update with a notification saying so, and you’ll be able to find the required rules at the bottom of the page.

Leave a Reply

Your email address will not be published. Required fields are marked *