title: Assign role to user Keycloak Admin Client
body: <p>I'm having a problem trying to assign role to user via keycloak admin client. It always returns bad request. First I created a new realm in keycloak with new client. I created couple of users and assigned all roles from realm-management client to one of the users. I used credentials of that user in KeycloakBuilder.</p>
  
  <p>Now admin client can create users, but assigning role to user returns 400 Bad Request.
  Following is the code-snippet</p>
  
  <pre><code>class KeycloakKonfig {
      var keycloak: Keycloak = KeycloakBuilder.builder()
          .serverUrl("http://localhost:8080/auth")
          .username("username")
          .password("password")
          .realm("realm")
          .clientId("clientId")
          .clientSecret("clientSecret")
  
          .resteasyClient(ResteasyClientBuilder().connectionPoolSize(20).register(CustomJacksonProvider()).build())
  
          .build()
  }
  </code></pre>
  
  <p>method body in controller</p>
  
  <pre><code>val savedRoleRepresentation = KeycloakKonfig().keycloak.realm("realm").roles().get("role").toRepresentation()
  KeycloakKonfig().keycloak.realm("realm").users().get("userId").roles().realmLevel().add(Arrays.asList(savedRoleRepresentation))
  </code></pre>
  
  <p>Thanks</p>