0

I want to dynamically assign Global Role and Specific Application access to a user in Cumulocity globally.But getting 422 status code back.

"error": "usermangement/Invalid Data", "message": "Could not Identify the role referenced by: https://xxxx.cumulocity.com/user/xxxx/groups/14/roles", "info": "https://www.cumulocity.com/guides/reference-guide/#error_reporting"

I am trying to invoke POST method for {{url}}/user/{{tenant}}/users/{{username}}/roles

2 Answers2

0

Actually , Global Role is also known as Groups in c8y. Hence we can usethe user reference API to assign global roles to a user.

POST {{url}}/user/{{tenant}}/groups/{{groupid}}/users

0

as far as i understand you, you are trying to add a user to a role, am i right?

curl --location --request POST '{{tenantURL}}/user/{{tenantId}}/groups/{{globalRoleId}}/users' \
--header 'Authorization: {{auth}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "user": {
        "id":"yourUserName","self":"https://tenant.cumulocity.com/user/tenantId/users/yourUserName"
    }
}'

And here is an example with filled in variables for adding a User to Global Reader Role:

curl --location --request POST 'https://sb.eu-latest.cumulocity.com/user/t138936816/groups/11/users'
--header 'Content-Type: application/json'
--data-raw '{
    "user": {
         "id":"sebu","self":"https://t138936816.eu-latest.cumulocity.com/user/t138936816/users/sebu"
            }
}'
sebu
  • 1
  • 1