Skip to content

Feedback - Lesson: Interacting with the WP REST API #3333

@nmanner

Description

@nmanner

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)

  1. Download version 1.0.1 of the Bookstore plugin.
  2. Extract the files in a new working directory.
  3. Run wp-env start in that directory to create a WP install with the plugin included and run the development site at localhost:8888.
  4. Open Postman and create a new GET request to http://localhost:8888/ to verify that Postman can reach the site.
  5. Add route wp-json/wp/v2/books to the base url and see that the endpoint is not found.
  6. Open the dashboard at http://localhost:8888 in your browser and navigate to 'Settings' -> 'Permalinks' and check that Permalink structure is set to 'Plain'.
  7. Replace wp-json in the Postman GET request URL with ?rest_route= so that the resulting URL is http://localhost:8888/?rest_route=/wp/v2/books, and send the request to see that it returns a 200 OK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting TriageIssues awaiting triage. See Training Team handbook for how to triage issues.[Content] FeedbackFeedback provided about content on Learn.[Type] BugSomething isn't working on the Learn website.

    Type

    No type

    Projects

    Status

    No status

    Status

    Awaiting Validation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions