Opened 7 years ago
Last modified 5 years ago
#43681 new defect (bug)
Incorrect HTTP status code in 'posts' query.
Reported by: | demitrimuna | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | REST API | Keywords: | has-patch needs-testing |
Focuses: | rest-api | Cc: |
Description
I am using the WordPress (v4.9.4) JSON API, specifically this URL:
http://.../wp-json/wp/v2/posts
This works great. When I request a 'status':
http://.../wp-json/wp/v2/posts?status=draft
I get this error:
{ "data": { "status": 400, "params": { "status": "Status is forbidden." } }, "code": "rest_invalid_param", "message": "Invalid parameter(s): status" }
It took me a bit to realize that the problem is not that the request (or status
keyword) is in valid, but that requesting drafts requires authentication.
I'd like to request that HTTP status 401 (unauthorized) be returned instead of 400 (bad request). The request is not bad, just requires authentication.
Attachments (1)
Change History (5)
#1
@
7 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Type changed from enhancement to defect (bug)
- Version changed from 4.9.4 to 4.4
@
6 years ago
Changes status 400 with 401 for unauthorized requests. keeps status 400 for wrong requests.
Note: See
TracTickets for help on using
tickets.
Converting to a bug considering the wrong HTTP status code is being returned here.
From a quick glance it seems as if a few errors are defaulting to a 400 error code.