Not Able To Send Rest Api Request Of Keycloak

Update User Attributes.
i am using postman to send request for that.
i am doing Following Procedure
Step 1: Generating Bearer Token By Providing Username,Password,grant_type and client_id
http://localhost:8080/auth/realms/{realm name}/protocol/openid-connect/token
in body : username: vijay, password: vijay, grant_type: password, client_id: {client name}

step 2:After that i am using put request to change some data of user by user id
http://localhost:8080/auth/admin/realms/users/{user id}
Passing in Body :
TenantId: ‘1234’,
Client_Claims: ‘READWRITE’

Passing bearer Token in Authorization;
I’ve Also Tried with basic auth by providing master username and password;

But I am Getting Error i.e.
Unknown Error Or Unauthorized access

If anyone faced same problem. please guide how to make a request.
my bearer token generating successfully.

Thanking you

Your API url for updating users looks wrong. It needs the realm name:


Also, the body that you are passing in (assuming you want it to update the user) needs to be a full UserRepresentation (Keycloak Admin REST API). You can’t use this method to just pass the fields you want changed. I’ve found it easiest to call GET on the user method, update the JSON with the changes I want made, and then call PUT with the updated JSON as the body.

Also, another note if you still get a Unknown Error Or Unauthorized access error, you need to make sure you are making the request with the access token within the timeout you have specified. Keycloak’s defaults are pretty short for use of an access token before it must be refreshed (30 or 60 seconds, I think).

I’ve tried with that but getting same error
PFA SS of settings:

Token Request Response

I’ve Also Increased Token Timeout from keycloak ui

is it right or which one is correct to increases token time

try with http://localhost:8080/auth/admin/realms/greytrix/users

make sure the realname has the correct name. The first letter can also be capital

I’ve also tried this but getting unknown error.

It might be easier to use the nodejs client to do this. Here is an example of how to use it: quick keycloak-nodejs-script · GitHub have a look at the tests of the project for more API examples GitHub - keycloak/keycloak-nodejs-admin-client: 🔑 NodeJS keycloak admin client