I need to update the existing user roles through REST service in Marklogic

20 Views Asked by At

How can I add/remove an existing user role through the REST service in Marklogic? if possible can you share the sample code?

1

There are 1 best solutions below

0
Mads Hansen On

You can use the REST endpoint PUT /manage/v2/users/{id|name}/properties.

For example, if you wanted to update the user test and assign them the admin role (and update the user description):

curl -X PUT -i --digest -u admin:admin -H "Content-Type:application/json" -d @payload.json http://localhost:8002/manage/v2/users/test/properties

with the following JSON in a file called payload.json:

{
  "description": "updated roles example",
  "roles": [{"role": "admin" }]
}