title: create user in keycloak 4.8.3 programmatically with java
body: <p>I want to create a user through keycloak admin client but I am  getting:</p>
  
  <blockquote>
    <p>Exception in thread "main" javax.ws.rs.ProcessingException: 
            javax.ws.rs.BadRequestException: HTTP 400 Bad Request</p>
  </blockquote>
  
  <p>Heading I expect returning the user created successfully but it generate 400 bad request error</p>
  
  <pre><code>String serverUrl = "http://localhost:8180/auth";
  String realm = "demo";
  String clientId = "idm-client";
  String clientSecret = "a200cdf6-ad72-4f6c-af73-5b8e1cc48876";
  
  Keycloak keycloak = KeycloakBuilder.builder() 
      .serverUrl(serverUrl) //
      .realm(realm) //
      .grantType(OAuth2Constants.CLIENT_CREDENTIALS) //
      .clientId(clientId) //
      .clientSecret(clientSecret).build();
  
  // Define user
  UserRepresentation user = new UserRepresentation();
  user.setEnabled(true);
  user.setUsername("tester1");
  user.setFirstName("First");
  user.setLastName("Last");
  user.setEmail("tom+tester1@tdlabs.local");
  user.setAttributes(Collections.singletonMap("origin", 
  Arrays.asList("demo")));
  
  // Get realm
  RealmResource realmResource = keycloak.realm(realm);
  UsersResource userRessource = realmResource.users();
  
  // Create user (requires manage-users role)
  Response response = userRessource.create(user);
  System.out.println("Repsonse: " + response.getStatusInfo());
  </code></pre>
  
  <p>The line that  generate the error is:</p>
  
  <pre><code>Response response = userRessource.create(user);
  </code></pre>