# X-Pack get users using Java API

**URL:** https://discuss.elastic.co/t/x-pack-get-users-using-java-api/134499
**Category:** Elasticsearch
**Created:** [June 4, 2018, 11:39pm UTC](https://discuss.elastic.co/t/x-pack-get-users-using-java-api/134499 "2018-06-04T23:39:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lengoyvaerts](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lengoyvaerts/32/6748_2.png) [@lengoyvaerts](https://discuss.elastic.co/u/lengoyvaerts)
#### Post date: [June 4, 2018, 11:39pm UTC](https://discuss.elastic.co/t/x-pack-get-users-using-java-api/134499/1 "2018-06-04T23:39:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)
#### Post date: [June 5, 2018, 2:06am UTC](https://discuss.elastic.co/t/x-pack-get-users-using-java-api/134499/2 "2018-06-05T02:06:59Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 3, 2018, 2:07am UTC](https://discuss.elastic.co/t/x-pack-get-users-using-java-api/134499/3 "2018-07-03T02:07:05Z")

</div>

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