# Admin API Status 400 Bad Requiest

**URL:** <https://forum.keycloak.org/t/admin-api-status-400-bad-requiest/4467>\
**Category:** Getting advice\
**Tags:** admin-rest\
**Created:** [August 25, 2020, 6:58am UTC](https://forum.keycloak.org/t/admin-api-status-400-bad-requiest/4467 "2020-08-25T06:58:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![corneil](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/corneil/32/491_2.png) [@corneil](https://forum.keycloak.org/u/corneil)\
**Post date:** [August 25, 2020, 6:58am UTC](https://forum.keycloak.org/t/admin-api-status-400-bad-requiest/4467/1 "2020-08-25T06:58:52Z")

</div>

I’m using the admin API in Java.  
When trying to create a user providing a login, firstName, lastName and password. I get BAD REQUEST error 400. I have configured the keycloak container with DEBUG logging and can see the authentication to the server with the realm-management clientId is successful.

Any ideas on what might be missing?

---

<div class="post-metadata">

**Author:** ![zonaut](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/zonaut/32/666_2.png) [@zonaut](https://forum.keycloak.org/u/zonaut)\
**Post date:** [August 25, 2020, 7:03am UTC](https://forum.keycloak.org/t/admin-api-status-400-bad-requiest/4467/2 "2020-08-25T07:03:52Z")

</div>

Check if the following helps you further [Keycloak Admin Client in Spring Boot](http://forum.keycloak.org/t/keycloak-admin-client-in-spring-boot/2547/2)

---

<div class="post-metadata">

**Author:** ![corneil](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/corneil/32/491_2.png) [@corneil](https://forum.keycloak.org/u/corneil)\
**Post date:** [August 25, 2020, 7:41am UTC](https://forum.keycloak.org/t/admin-api-status-400-bad-requiest/4467/3 "2020-08-25T07:41:35Z")

</div>

Thanks, I tried using admin-cli and could also authenticate but then BAD REQUEST again with nothing in the logs.  
loglevel =TRACE it is.

---

<div class="post-metadata">

**Author:** ![zonaut](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/zonaut/32/666_2.png) [@zonaut](https://forum.keycloak.org/u/zonaut)\
**Post date:** [August 25, 2020, 7:50am UTC](https://forum.keycloak.org/t/admin-api-status-400-bad-requiest/4467/4 "2020-08-25T07:50:26Z")

</div>

maybe you could provide more information about the command you are executing.  
Also take a look in the returning headers, sometimes these also contain more information.

---

<div class="post-metadata">

**Author:** ![corneil](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/corneil/32/491_2.png) [@corneil](https://forum.keycloak.org/u/corneil)\
**Post date:** [August 26, 2020, 5:32am UTC](https://forum.keycloak.org/t/admin-api-status-400-bad-requiest/4467/5 "2020-08-26T05:32:48Z")

</div>

So eventually the solution was:  
Create a new user that will be the admin user lets called `user-admin`  
Assign `user-admin` roles from the `realm-management` client.  
The calls needed to use the `admin-cli` clientId with the `user-admin` username and password.  
Interesting that using `realm-managment` clientId and clientSecret didn’t work.
