A REST error tells you where the request stopped. 404, 400, 401, 403 or your own error โ each one points to a different step. This module turns status codes into a debugging map.
| Course | WordPress REST API Course ยท Module 8 of 9 ยท Stage 3 "Ship it" |
| Learn | Request order in WP_REST_Server, the /wp-json/ index, curl with Application Passwords, WP-CLI cache commands |
| How | Core order from class-wp-rest-server.php, real CLI from 4WP Weather, the checks we run before every wp.org upload, interview questions after every lesson |
Where did it stop?
flowchart LR
R["Route?<br/>404 rest_no_route"] --> A["Args?<br/>400 rest_invalid_param"]
A --> P["Permission?<br/>401 / 403 rest_forbidden"]
P --> C["Callback<br/>200 or your error"]
classDef e fill:#feebeb,stroke:#f93e3e,color:#1e293b
classDef ok fill:#e8f6f0,stroke:#49cc90,color:#1e293b
class R,A,P e
class C ok
Args are checked before permissions, so a guest with a bad param gets 400, not 401.
Before โ after
| Before | After Module 8 |
|---|---|
| "It doesn't work" โ no idea why | the status code points to the step |
| curl gets 401 while the browser works | an Application Password for curl |
| Same old answer after a fix | wp forwp-weather flush-cache |
| Manual clicking before release | scripted checks before every upload |
You'll be able to answer
- In which order does WordPress check route, args and permissions?
- How do you authenticate curl against the WordPress REST API?
- How do you list every route registered on a site?