[wp-trac] [WordPress Trac] #43681: Incorrect HTTP status code in 'posts' query.
WordPress Trac
noreply at wordpress.org
Mon Apr 2 23:43:42 UTC 2018
#43681: Incorrect HTTP status code in 'posts' query.
-------------------------+-----------------------------
Reporter: demitrimuna | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.9.4
Severity: normal | Keywords:
Focuses: rest-api |
-------------------------+-----------------------------
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43681>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list