OCS Share API Permissions dont work

Hello,

I try to create a share with the following:

curl --user “admin:PASSWORD” “https://DOMAIN/ocs/v1.php/apps/files_sharing/api/v1/shares” --data ‘path=/Test’ --data ‘shareType=3’ --data ‘name=welcome.txt’ --data ‘permissions=31’

The response I get:
<permissions>1</permissions>

Updating via PUT gives me:

<ocs>
 <meta>
  <status>failure</status>
  <statuscode>400</statuscode>
  <message>Can't change permissions for public share links</message>
  <totalitems></totalitems>
  <itemsperpage></itemsperpage>
 </meta>
 <data/>
</ocs>

Nextcloud also has this bug, I hoped you guys at least dont. Or is there something wrong with the request?

Thanks.

There is no bug at all, it’s your request. You shouldn’t accuse others.

It works like a charm.

$ curl -n -X POST https://domain/ocs/v1.php/apps/files_sharing/api/v1/shares --data 'name=welcome.txt' --data 'path=/Test/welcome.txt' --data 'shareType=3' --data 'permissions=31'
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>100</statuscode>
  <message/>
  <totalitems></totalitems>
  <itemsperpage></itemsperpage>
 </meta>
 <data>
  <id>58</id>
  <share_type>3</share_type>
  <uid_owner>abu</uid_owner>
  <displayname_owner>Alfred Bühler</displayname_owner>
  <permissions>1</permissions>
  <stime>1653895297</stime>
  <parent/>
  <expiration/>
  <token>YKJVpjOiIYuJjCz</token>
  <uid_file_owner>abu</uid_file_owner>
  <displayname_file_owner>Alfred Bühler</displayname_file_owner>
  <additional_info_owner>abu</additional_info_owner>
  <additional_info_file_owner>abu</additional_info_file_owner>
  <path>/Test/welcome.txt</path>
  <mimetype>text/plain</mimetype>
  <storage_id>home::abu</storage_id>
  <storage>1</storage>
  <item_type>file</item_type>
  <item_source>904</item_source>
  <file_source>904</file_source>
  <file_parent>903</file_parent>
  <file_target>/welcome.txt</file_target>
  <name>welcome.txt</name>
  <url>https://domain/index.php/s/YKJVpjOiIYuJjCz</url>
  <mail_send>0</mail_send>
  <attributes/>
 </data>
</ocs>

BTW, setting permission 31 for public links is superfluous, as it will be ignored and permission 1 will be applied.

1 Like

I am sorry, I had a bad day. I will check it, thank you so much. I tried your request but it isnt working for me, still permission 1. But thanks anyway.

Tell me more details, please.