11

Since woocommerce released the 2.1 version with REST API feature, I tried to use it: I activated the API on my woocommerce admin panel but when I try to call the curl: http://www.mydomain.com/wc-api/v1/

the response is a 404 file not found error.

I tried to check everything in internet, I've read woocommerce docs but I cannot figure out what I have to do: probably some setting in the server apache or php... I don't know..

Thank you

manlio
  • 18,345
  • 14
  • 76
  • 126
user1142705
  • 131
  • 1
  • 1
  • 5

5 Answers5

33

Try going, on the Admin Panel, to Settings -> Permalinks. On Default Settings radio group, select the "Post name" one. Save the changes.

Worked for me; hope for you too. :)

Source: this blog post.

EDIT: Website is not available, so I put its Wayback Machine URL.

devrique
  • 526
  • 4
  • 10
8

I was having this same issue. I had forgotten to turn on the pretty perma links, but doing that didn't solve it for me.

I also had to update my apache virtual host file because the AllowOverride was defaulted to None.

<Directory /var/www/wordpress/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
</Directory>

Once I updated this, and reloaded the Apache service, the API worked for me.

talonmies
  • 70,661
  • 34
  • 192
  • 269
Randy Shelford
  • 142
  • 1
  • 7
  • Is this also possible for a Node.js server? – Yvonne Marggraf Apr 11 '18 at 13:18
  • @Yvonne.J.M I don't know that I understand the question. The apache server that needed this applied to it was the server running the wordpress website, not the server I was trying to make the API calls from. I'm not entirely sure where the Node.js server would fit into this. – Randy Shelford Apr 17 '18 at 16:27
4

It was simply a matter of enabling URL rewriting in WordPress. Basically, go to Settings -> Permalinks and make sure the first rewriting option is set to Posts Name.

ahmedkandil
  • 477
  • 3
  • 6
0

Apart from answer shared above: Settings -> Permalinks. On Default Settings radio group, select the "Post name" one. Save the changes.

I also had to manually update .htaccess file to reflect the changes I made (permalinks to "Post name", and the little Wordpress help text shown on the bottom of the page was really helpful:

If your .htaccess file was writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.

Basically copy the new mod_rewrite rules as instructed by Wordpress above and manually update your .htaccess file! doing this worked for me!

Ayyoub
  • 4,581
  • 2
  • 19
  • 32
0

I use MAMP to run the Wordpress and utilizing the web server Nginx. When I tried running REST API, it returns 404 status not found. I set permalinks to 'Post Name' but it still didn't work.

Then I changed the web server to Apache. It works.

ulfa
  • 17
  • 6