1

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?

cgrim
  • 4,890
  • 1
  • 23
  • 42
Mustafa
  • 59
  • 1
  • 8

1 Answers1

1

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": "some-external@user.com",
    "permission": "Read",
    "begin": "2020-06-01T00:00:00+02:00",
    "end": "2020-06-30T00:00:00+02:00",
    "notify": true,
    "comment": "notify@me.com"},
  "context": {},
  "input": "2d28e87f-0753-4cfc-9f9b-b17d424aa6a7"
}
cgrim
  • 4,890
  • 1
  • 23
  • 42
  • tahnks a lot, you saved my time. – Mustafa Jun 08 '20 at 17:48
  • I'm glad it worked for you. Can you please [accept the answer](https://meta.stackexchange.com/a/5235/789510)? It will help others when solving the same problem ;-) Thanks – cgrim Jun 09 '20 at 20:24