Mustafa
Mustafa

Reputation: 69

How can assign permission to user for specific folder in nuxeo using rest api

I upload many files to Nuxeo server using rest API. Now I need to add permission to users. I use http://localhost:8080/nuxeo/api/v1/id/file-id/@acl endpoint with payload:

{  
    "username": "username",
    "permission": "ReadWrite"
} 

But it is not working. The error is:

{
    "entity-type": "exception",
    "status": 405,
    "message": "javax.ws.rs.WebApplicationException"
}

How can I do it? Is there any endpoint for that?

Upvotes: 1

Views: 482

Answers (1)

cgrim
cgrim

Reputation: 5031

Permission can be added by the Document.AddPermission operation available on the http://localhost:8080/nuxeo/api/v1/automation/Document.AddPermission endpoint.

Here is a curl example call used to add ReadWrite permission for editor user to the document with ID 2d28e87f-0753-4cfc-9f9b-b17d424aa6a7:

curl -X POST -u Administrator:Administrator \
http://localhost:8080/nuxeo/api/v1/automation/Document.AddPermission \
-H "Content-Type: application/json" \
-d '{"params":{"users":["editor"],"permission":"ReadWrite"},"input":"2d28e87f-0753-4cfc-9f9b-b17d424aa6a7"}'

And here is an example payload when you want to add permission for external user:

{
  "params": {
    "users":[],
    "email": "[email protected]",
    "permission": "Read",
    "begin": "2020-06-01T00:00:00+02:00",
    "end": "2020-06-30T00:00:00+02:00",
    "notify": true,
    "comment": "[email protected]"},
  "context": {},
  "input": "2d28e87f-0753-4cfc-9f9b-b17d424aa6a7"
}

Upvotes: 1

Related Questions