-
Notifications
You must be signed in to change notification settings - Fork 122
Description
Type of feedback
//content
Description
I was going through this lesson: Interacting with the WordPress REST API and I was confused by the URL used for the API endpoints in the example, which is https://learn.test/wp-json/wp/v2/books. I knew that the base URL should be my localhost when running a local dev environment, but simply replacing https://learn.test with http://localhost:8888 didn't work, it only got me a 404. Only after reading Routes and Endpoints in the documentation, I found out that I needed to replace wp-json with ?rest_route= since permalinks were set to plain by default in the WP install. I think it would be helpful to mention this in the lesson, and not just refer to 'the URL to your local books endpoint', since many learners may start the lesson with the plugin files from the repository and not have the permalinks configured to enable such routes as in the example.
Step-by-step reproduction instructions (optional)
- Download version 1.0.1 of the Bookstore plugin.
- Extract the files in a new working directory.
- Run
wp-env startin that directory to create a WP install with the plugin included and run the development site atlocalhost:8888. - Open Postman and create a new GET request to
http://localhost:8888/to verify that Postman can reach the site. - Add route
wp-json/wp/v2/booksto the base url and see that the endpoint is not found. - Open the dashboard at
http://localhost:8888in your browser and navigate to 'Settings' -> 'Permalinks' and check that Permalink structure is set to 'Plain'. - Replace
wp-jsonin the Postman GET request URL with?rest_route=so that the resulting URL ishttp://localhost:8888/?rest_route=/wp/v2/books, and send the request to see that it returns a200 OK.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status