X-Pack get users using Java API


(Lengoyvaerts) #1

Hi,

I'm trying to list all users using X-Pack Java API:

GetUsersResponse response = xPackClient.security().prepareGetUsers().get();
return response.users();

All I get is a list of these Json objects:

[
  {
    "runAs": false,
    "fragment": false
  },
  {
    "runAs": false,
    "fragment": false
  }
]

Where is the other info?

Regards,
Len


(Tim Vernum) #2

How are you producing this output?
The GetUsersResponse is a Java object, not a blob of JSON, so it looks like whatever you are doing with that object is the cause of your issue.

My guess is that you are trying to treat the User object as a java bean (hence the isRunAs and isFragment methods get rendered as JSON) but it isn't a Bean, and you can't use it that way.
If you need it as JSON, then you want to use the toXContent method, or call Strings.toString(user) which will call toXContent and produce JSON output.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.