How to create a new Group with realmRoles mapping

Hi y’all.

I’m currently trying to automatize the creation of some Groups in over the REST-API. The documentation explicitly links to the GroupRepresentation, that allows for the specification of the realmRoles for the group. This is exactly the feature I need, however when I make the call, the Group is created, as expected, but without the mapping.

The payload for the call is as follows:

{
    "name": "administrators",
    "attributes": {
        "created_by": "automatic-install"
    },
    "realmRoles": [ "admin" ]
}

Is there something I’m missing? Keycloak doesn’t return no error, it seems to just ignore the parameter entirely. I can’t even find a mention of the realmRoles in the trace logs.

Looking in the code (GroupsResource.addTopLevelGroup and GroupResource.updateGroup), it appears that it ignores everything but the name, id, and attributes.

1 Like

I have solved it by using the Client Role Mapping API.