无法通过 Keycloak Admin Rest API 添加组属性

cha*_*ani 4 keycloak

我正在发送请求以PUT /{realm}/groups/{id}将组属性添加到现有组。

PUT 请求的正文如下所示:

{"attributes":{"id":123}}
Run Code Online (Sandbox Code Playgroud)

它失败并返回 500 错误。

该文档不清楚“Map”模式的格式。https://www.keycloak.org/docs-api/6.0/rest-api/#_grouprepresentation显示“attributes”字段类型为“Map”,但未定义。我尝试了几种格式,例如:

{"attributes":[{"id":123}]}
{"attributes":{"key":"id","value":123}}
{"attributes":[{"key":"id","value":123}]}
Run Code Online (Sandbox Code Playgroud)

但它们都不起作用。

什么是“Map”架构?为什么我的请求返回 500?

rav*_*iru 11

您可以与属性一起创建组,请求正文将是

{"name":"myGroup","attributes":{"attr1":["value1"]}}
Run Code Online (Sandbox Code Playgroud)

有两个属性应该是这样的

{"name":"mygroup","attributes":{"attr2":["value2"],"attr1":["value1"]}}"
Run Code Online (Sandbox Code Playgroud)