'wordpress REST API draft posts not showing

Using the Wordpress REST API I am trying to get draft posts only. However the API responds with only the published posts when I pass the query in both cases.

A: http://localhost/wp-json/wp/v2/posts?status=draft

B: http://localhost/wp-json/wp/v2/posts?filter[post_status]=draft

How can I see only the draft posts? I am using the JWT Authentication for WP-API plugin for authentication but disabling this doesn't seem to change anything.



Solution 1:[1]

This is because just installing the JWT Auth plugin doesn't solve the problem. There are also some modifications to be performed on the .htaccess file as well as in wp-config.php.

I hit a similar problem but with private posts, so I created a video detailing the steps you need to follow to install and configure the JWT Authentication plugin.

https://youtu.be/Mp7T7x1oxDk

Solution 2:[2]

for getting draft posts you should send an Authorization token, so you can use JWT Authentication for WP-API plugin for getting it and use it anywhere, and for getting posts with drafts status you should send 'status': 'draft' as a param in your request, also if you want to get all of status you should send 'status': 'any' in your params in request. :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Adrian Oprea
Solution 2 ICIC