# Keycloak API UserRepresentation.getgroups always null

**URL:** <https://forum.keycloak.org/t/keycloak-api-userrepresentation-getgroups-always-null/15452>\
**Category:** Getting advice\
**Created:** [May 10, 2022, 12:59pm UTC](https://forum.keycloak.org/t/keycloak-api-userrepresentation-getgroups-always-null/15452 "2022-05-10T12:59:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lexuijthof](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/lexuijthof/32/5699_2.png) [@lexuijthof](https://forum.keycloak.org/u/lexuijthof)\
**Post date:** [May 10, 2022, 12:59pm UTC](https://forum.keycloak.org/t/keycloak-api-userrepresentation-getgroups-always-null/15452/1 "2022-05-10T12:59:35Z")

</div>

When Using the API (17.0.1) and call either :  
UsersResource.search(userName, true) or  
UsersResource.get(id).toRepresentation()

i get a UserRepresentation object.  
Eventhough the found users are part of a group the groups (List) field is null.

When I call UsersResource.get(id).groups() i do see them.

How can i make sure that the UserRepresentation.groups field isn’t null
