How to add new user in keyclaok using postman? I am able to get token from keyclaok but not able to create user

I am trying to add a user in keyclaok server using postman but i am not able to create.

Postman request:

first of all i got the token from keycloak:
http://54.218.218.85:8080/auth/realms/ctms/protocol/openid-connect/token

request:

  client_id=ctms-app
  grant_type=password
  username=admin
  password=password

response:

{
     "access_token": $Token,
     "expires_in": 300,
     "refresh_expires_in": 1800,
     "refresh_token":  $Token
     "token_type": "bearer",
     "not-before-policy": 0,
     "session_state": "4425bee9-c243-4d1d-89ed-7c6bcc3f37a0",
     "scope": "email profile"
}

I was got the token from keyclaok After that i was trying to create the user using postman from below api request:

Method : POST URL : http://localhost:8080/auth/admin/realms/ctms/users

Header : key : Authorization , Value : bearer @Token

Request JSON Type in Body:

 {
   "enabled": true,
   "attributes": {},
   "emailVerified": "",
   "firstName": "DDDDDD",
   "lastName": "WWWWWWW",
   "email": "wwww@aaa.com",
   "credentials":{"type":"password",
            "value":"password",
            "temporary":false
          }
}

Getting Response 403 Forbidden

{ “error”: “unknown_error” }

I am making a custom lonin page with New User & Sign-up user option but i am not able to create new user If anyone please tell me how to add new user in keyclaok using postman

1 Like

Hi Team, please help us to create new user using postman.

My gues, you don’t have proper permissions and that is a reason for 403 response. See 403 Error by GET REST request

Thanks for giving response, I able to create user but when i add credentials parameter then it will throw below error.

16:52:54,848 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (default task-5) Uncaught server error: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.util.ArrayList<org.keycloak.representations.idm.CredentialRepresentation> out of START_OBJECT token
at [Source: (io.undertow.servlet.spec.ServletInputStreamImpl); line: 9, column: 17] (through reference chain: org.keycloak.representations.idm.UserRepresentation[“credentials”])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1442)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1216)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1168)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.handleNonArray(CollectionDeserializer.java:332)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:265)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)