GET requests to the wp-api requires authentication
-
I’m using GET requests to fetch data from a wordpress site running WP 4.7 (not the WP-API plugin). If I fetch a single post or a page, the API returns all data as expected.
But if I try to fetch a collection of posts with a URL like this:
https://devserver.corp.com/wp-json/wp/v2/posts
it returns an empty array.
I can test this by going to that URL (a dev server behind a firewall) in my browser. If I’m logged in to the WP site, I get an array of posts. If I log out, I get an empty array. Just two square brackets.
But if I go to the endpoint for a single post, such as
https://devserver.corp.com/wp-json/wp/v2/posts/855
Then I always get a complete post object, if I’m logged in or not logged in.
Does anyone know what’s going on? GET request should not require authentication.
BTW, this is not a CORS issue. When I set up my app to do a GET request on a collection of posts, it returns an empty array and a 200 code. If I pass authentication with my request, it returns the array with data (but then its very slow).
So I need to be able to do GET requests without authentication.
- The topic ‘GET requests to the wp-api requires authentication’ is closed to new replies.