WordPress / WordPress/Learn

Feedback - Lesson: Interacting with the WP REST API

Open Beginner friendly
#3,333 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Content] Feedback [Type] Bug Awaiting Triage
Dominant language
PHP
Stars
333
Forks
127
Avg merge
1d 7h
Merged PRs (30d)
11

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)

  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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the “Interacting with the WordPress REST API” lesson linked in the issue and reproduce the endpoint request with permalinks set to Plain. Update the lesson to explain the ?rest_route=/wp/v2/books alternative alongside the pretty URL, then verify that the documented request returns the books endpoint successfully in the described local setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
wordpress
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.