title: Keycloak - using admin API to add client role to user
body: <p>I'm triyng to use keycloak AdminAPI (<a href="https://www.keycloak.org/docs-api/3.0/rest-api/index.html#_users_resource" rel="noreferrer">https://www.keycloak.org/docs-api/3.0/rest-api/index.html#_users_resource</a>) to create user and assign client roles. I'm receiving correct token, and user is created but assigning roles return 404 </p>
  
  <p>I'm using Postman to connect with API:</p>
  
  <pre><code>/auth/realms/{realmName}/protocol/openid-connect/token
  Content-Type application/x-www-form-urlencoded &lt;-with parameters ofc
  /auth/admin/realms/{realmName}/users
  
  Content-Type application/json
  Authorization Bearer {TOKEN}
  Body:
  </code></pre>
  
  <pre><code>{
     "username": "name",
     "enabled": true,
     "emailVerified": false,
     "firstName": "first",
     "lastName": "last",
     "credentials": [
         {
             "type": "password",
             "value": "newPas1*",
             "temporary": false
         }
     ]
  }
  </code></pre>
  
  <p>Above works for me, but the next one don't</p>
  
  <pre><code>/auth/admin/realms/{realmName}/users/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/role-mappings/clients/realm-management
  
  Content-Type application/json
  Authorization Bearer {TOKEN}
  Body:
  </code></pre>
  
  <pre><code>{
     "roles": [
         {
             "id": "0830ff39-43ea-48bb-af8f-696bc420c1ce",
             "name": "create-client",
             "description": "${role_create-client}",
             "composite": false,
             "clientRole": true,
             "containerId": "344e7c81-e7a2-4a43-b013-57d7ed198eee"
         }
     ]
  }
  </code></pre>
  
  <p>where 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx' is userID returned during creation and create-client role exists</p>
  
  <p>I need a way to add client role via Http request. I saw there are some keycloack implementation for java but I'm using .NET CORE so there will be the target implementation but I need to have working request first as you may gues</p>