Search code examples
wordpresswoocommercewordpress-rest-apiwoocommerce-rest-api

WooCommerce REST API endpoints don't exist


After installing a fresh Wordpress 4.8 instance and the latest version of WooCommerce 3.0.8, we are trying to understand how to use the WooCommerce REST API.

From their documentation, it seems to be pretty straightforward, but we just get 404s on each endpoint.

We're new to both Wordpress and WooCommerce, so the different things we read can be misleading and often contradict one another...

  • The Wordpress index endpoint gives us a 404.
  • Any WooCommerce (eg /wp-json/wc/v2/products) gives us a 404.
  • As the Wordpress demo REST site answers, ours serves a 404. Is it even the API base WooCommerce is relying on (confused...)?

We are trying to understand whether we need some more plugin to enable these REST endpoints. We tried adding numerous without luck.

How to get those REST endpoints enabled? Are we reading an outdated documentation? Is there some Apache/nginx/IIS/LiteSpeed/LiteSpeed trickery involved here (We cannot find any PHP file with those names, so we're wondering if maybe we're missing a rewrite rule)?


Solution

  • 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.