WordPressPCL: Unable to get username from user

Hello everyone,

I was unable to get the users usernames with your api. I am using the function GetAll(True, True) to get all users. But the username is not set in the returned User objects. In the documentation https://developer.wordpress.org/rest-api/reference/users/#arguments there is a context argument, which can be either view, embed or edit. I noticed, that most of the users attributes are available in the edit context. But you can only specify to use the embed context or not with your api. Is that the reason why I am no receiving the usernames of the users?

Thank you very much for your help!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

@MarvinKlar if you want to perform the request with special context (not view), you should use QueryBuilder. For your purpose the following code might be helpful:

var userQuery = new UsersQueryBuilder {
     Context=Context.Edit,
//another conditions
};
var usersWithUsername = client.Users.Query(userQuery, true);

so this code should return users with username property