Can't add group attribute via Keycloak Admin Rest API

Viewed 1323

I'm sending a request to PUT /{realm}/groups/{id} to add a group attribute to an existing group.

The body of PUT request looks like this:

{"attributes":{"id":123}}

It's failing and returning 500 error.

The documentation is not clear about the format of "Map" schema. https://www.keycloak.org/docs-api/6.0/rest-api/#_grouprepresentation shows "attributes" field type is "Map" but it's not defined. I tried several formats, like:

{"attributes":[{"id":123}]}
{"attributes":{"key":"id","value":123}}
{"attributes":[{"key":"id","value":123}]}

but none of them is working.

What is "Map" schema and why is my request returning 500?

1 Answers

You can create group along with attribute, request body will be

{"name":"myGroup","attributes":{"attr1":["value1"]}}

with two attributes it should be something like this

{"name":"mygroup","attributes":{"attr2":["value2"],"attr1":["value1"]}}"
Related