Documentation-Issue-Tracker
Documentation-Issue-Tracker copied to clipboard
Doc Missing: REST API is only accessible until Permalinks configured.
I am working on a project that uses REST API to manage WordPress sites.
I kept getting empty response from REST API calls (for instance: curl --user "username:password" localhost:8070/wp-json/wp/v2/posts). After debugging for several hours I found out that the REST API wp-json endpoint won't be available till permalinks got configured.
I can't find anything related to this step in the REST API documentation. Should we add this to the docs?
You shouldn't assume that Permalinks are configured on a site, and should use the HTTP Header to discover the endpoint, for example:
$ curl -I https://example.org/
Link: <https://example.org/?rest_route=/>; rel="https://api.w.org/"
...
<link rel="https://api.w.org/" href="https://example.org/?rest_route=/" />
This likely isn't something that needs documenting, but I'll transfer this issue to the Docs issue tracker.
This is probably covered by the Discovery page: https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/
Heads up @WordPress/docs-issues-coordinators, we have a new issue open. Time to use 'em labels.
You shouldn't assume that Permalinks are configured on a site, and should use the HTTP Header to discover the endpoint, for example:
Thank you for the response. That curl command was just an example, I do have HTTP Header attached when calling REST API in my dev/production sites.
And my point is: exactly because user shouldn't assume permalinks are configured on a site, the REST API documentation should alert user that -- if the REST API isn't working for your website, double check if permalinks are configured