Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

404 on http://localhost/wp-json/wp/v2/posts in wordpress using REST API V2

I am getting a 404 on http://localhost/wp-json/wp/v2/posts route. I changed permalink type to plain. Still got the same issue.

If its useful, I am ubuntu 16.04 desktop recent upgrade from 15.10, suffered issues with php5.6 to 7.0 upgrade. Am now on php 7.0

Edit1: Tried every other permalink setting combination, no results!

like image 641
hungryWolf Avatar asked Oct 23 '25 09:10

hungryWolf


2 Answers

http://localhost/?rest_route=/wp/v2/posts should works. Refer https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/ for details.

like image 167
Murat Uygar Avatar answered Oct 26 '25 02:10

Murat Uygar


You need to give permission to your wp-content folder. For the change the permission please use below command in terminal.

sudo chmod -R 755 wp-content/

After the change permission is still show 404 error then allow AllowOverride for apache, below is the step:

navigated to /etc/apache2/sites-enabled and opened 000-default

All of the AllowOverride variables were set to None, which I replaced with All.

After this change enable mod using below command:

 a2enmod rewrite

And restart the apache service below is the command:

sudo service apache2 restart
like image 41
Vishal Gupta Avatar answered Oct 26 '25 02:10

Vishal Gupta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!