Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

REST API URL to change the user role in Ranger?

avatar
Super Collaborator

Right now, Ranger provides two roles - "Admin" and "User". When I added a new user in OS, Ranger usersync created its login credentials for Ranger UI but the role appointed is User. I am trying the following REST API to change the role to Admin so that it can create new policies:

curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -u admin:admin http://sandbox.hortonworks.com:6080/service/xusers/users -d '{"name":"tom","role":["ROLE_SYS_ADMIN"]}'

There is no output or any error. Please help

1 ACCEPTED SOLUTION

avatar
Cloudera Employee
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
4 REPLIES 4

avatar
Super Collaborator
@mrizvi

Please use /service/users end point and for update use PUT.

curl -u admin:admin -X PUT -H "Accept: application/json" -H "Content-Type: application/json" http://`hostname -f`:6080/service/users -d @test.json

where test.json is your json pay-load.

avatar
Super Collaborator

Thanks @Ramesh Mani, Just tried this, still nothing happened. I guess there is a problem with json payload. I am using '{"name":"tom","userRoleList":"ROLE_SYS_ADMIN"}'

avatar
Cloudera Employee
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login

avatar
Super Collaborator

It worked, thanks a lot @jhorsch. I was missing some mandatory fields in json payload, that should be the reason for the error.