Hello, I’m trying to update a user in a specific realm as admin-cli. I have set up Postman and I’m able to return a list of all users in the realm, and also access a specific user. But when trying to update that specific user, I get this error:
[org.keycloak.services.resources.admin.UserResource] (executor-thread-9) Could not update user!: java.lang.NullPointerException: Cannot invoke "org.keycloak.representations.idm.UserRepresentation.isEnabled()" because "rep" is null
at org.keycloak.services.resources.admin.UserResource.updateUser(UserResource.java:169)
This is the request:
PUT http://localhost:8080/admin/realms/bikefolder/users/5c2b646a-2964-438e-8b03-265dc64f113a
{
"attributes": {
"test": "test"
}
}
Does anyone have a clue what could be the problem?
You have to include the full representation. These update endpoints don’t “overlay” changes. The recommended practice is to do a GET for the user you want to update, change the values in the representation you get, and then PUT that representation back.
Can you send the full request you are using? A curl or something like that, so we can see all of the headers you are sending.
Also, one useful “hack” is to use the Keycloak Admin UI to do a sample user update with the browser network inspector open, copy the request, and make sure you are doing the same thing.