Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc Missing: REST API is only accessible until Permalinks configured. #1825

Open
tybalex opened this issue Jan 21, 2025 · 3 comments
Open

Doc Missing: REST API is only accessible until Permalinks configured. #1825

tybalex opened this issue Jan 21, 2025 · 3 comments

Comments

@tybalex
Copy link

tybalex commented Jan 21, 2025

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?

@dd32
Copy link
Member

dd32 commented Jan 21, 2025

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/

@dd32 dd32 transferred this issue from WordPress/wordpress.org Jan 21, 2025
Copy link

Heads up @WordPress/docs-issues-coordinators, we have a new issue open. Time to use 'em labels.

@tybalex
Copy link
Author

tybalex commented Jan 21, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants