WP API V2 returning Invalid User ID

I want to display the list of posts from my wordpress blog on someother site along with the author name, title, date and description. Hence, I decided to use WP REST API V2. As per WP REST API Documentation I retrived the data in JSON format by following example URL http://example.com/wp-json/wp/v2/posts?_embed. I get all the information except author name.
Here is the partial JSON

 .........
 ........
 "_embedded": {
      "author": [
        {
          "code": "rest_user_invalid_id",
          "message": "Invalid user ID.",
          "data": {
            "status": 404
          }
        }
      ],
     ........
     ........

I also get same error if I try to visit the following link http://example.com/wp-json/wp/v2/users/1. I don’t understand why this error occur even though the user exist. Does it deal with authentication?

Note: I had earlier modified a field in the WP database so that the actual user name is not displayed in urls and posts. However, I think this must not affect the JSON output because an another alias for user name is already present and displayed in my blog. Also, the same entries of my blog is displayed on another wordpress blog by a wordpress plugin which also shows the author name.

Please help me I am stuck and unable to find solution.

3 Answers
3

Wordfence blocks the User endpoint from the public. In settings there is a checkbox you can unselect to make it visible in the WP Rest API again.

Leave a Comment