Get Error 404 when adding a user to group (or role to user) with admin client


I have an application with Spring-boot 2.7.x, Keycloak 20.0.5 (try with Keycloak 21 with the same issue)

I can create Realm, add roles, add group and users without probleme.


  • get an 404 error when adding group to an UserResource : userResource.joinGroup(group);
  • get an 404 error when adding user to an GroupResource : realm.groups().group(group).members().add(userResource.toRepresentation());
  • get an error 404 when associates role to a group
  • get no error when adding a RoleRepresentation to UserResource, but without effect : userResource.roles().realmLevel().add(Collections.singletonList(realm.roles().get(;

I use this code to add a role to a group :

  • RoleRepresentation role = REALM.roles().get(roleName).toRepresentation();
    RoleScopeResource roleScope = REALM.groups().group(groupName).roles().realmLevel();

all user, user_id, role name, group name are correct and well created in the realm

Any idea ?
Thanks by advance

joinGroup param is a ID ,not name , like ā€˜193b6031-3afc-4a8a-bdb2-7bd78aa5ef9eā€™