OCS Share API - "permissions" parameter has no effect
Hello,
Thank's for Nextcloud !
I am the documentation : https://docs.nextcloud.com/server/stable/developer_manual/client_apis/OCS/ocs-share-api.html#create-a-new-share
I'm looking to create the share of a write-enabled file with the OCS Share API
But the "permissions" parameter seems to have no effect ...
My code :
$cURLConnection = curl_init();
$params=array (
'path' => './t1.md',
'shareType' => 3,
'permissions' => 19,
'password' => ''
);
curl_setopt($cURLConnection, CURLOPT_URL, 'https://'.$username.':'.$password.'@'.$nextcloud_hostname.'/ocs/v2.php/apps/files_sharing/api/v1/shares?format=json');
curl_setopt($cURLConnection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURLConnection, CURLOPT_HTTPHEADER, array(
'OCS-APIRequest: true'
));
curl_setopt($cURLConnection, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($cURLConnection, CURLOPT_POSTFIELDS, $params);
$phoneList = curl_exec($cURLConnection);
curl_close($cURLConnection);
$jsonArrayResponse = json_decode($phoneList);
var_dump($jsonArrayResponse);
The var_dump say permissions = 17 :-/
object(stdClass)#4 (1) {
["ocs"]=>
object(stdClass)#2 (2) {
["meta"]=>
object(stdClass)#1 (3) {
["status"]=>
string(2) "ok"
["statuscode"]=>
int(200)
["message"]=>
string(2) "OK"
}
["data"]=>
array(1) {
[0]=>
object(stdClass)#3 (31) {
["id"]=>
string(2) "57"
["share_type"]=>
int(3)
["uid_owner"]=>
string(5) "david"
["displayname_owner"]=>
string(5) "david"
["permissions"]=>
int(17)
[...]
}
If I manually change the file permission in nextcloud (write permission), then I GET the share (https://docs.nextcloud.com/server/stable/developer_manual/client_apis/OCS/ocs-share- api.html # get-information-about-a-known-share) I get permissions = 19 :
object(stdClass)#4 (1) {
["ocs"]=>
object(stdClass)#2 (2) {
["meta"]=>
object(stdClass)#1 (3) {
["status"]=>
string(2) "ok"
["statuscode"]=>
int(200)
["message"]=>
string(2) "OK"
}
["data"]=>
array(1) {
[0]=>
object(stdClass)#3 (31) {
["id"]=>
string(2) "57"
["share_type"]=>
int(3)
["uid_owner"]=>
string(5) "david"
["displayname_owner"]=>
string(5) "david"
["permissions"]=>
int(19)
I tried with the value 1, 2, 10, 31 ... none seems to have an effect ... yet the rest of the arguments have an effect (password for example)
I guess it's a bug ...
Nextcloud 19.0.3 / Apache / PHP 7.3 / Mysql
I can add that some of check is done, because when entering arbitary number (permissons=100) i get error
<?xml version="1.0"?>
<ocs>
<meta>
<status>failure</status>
<statuscode>404</statuscode>
<message>invalid permissions</message>
</meta>
<data/>
</ocs>
Otherwise Share permission is always 1 (read only)
Same experience in Nextcloud 20.0.8RC1.
Have you tried 20.0.8 stable release, @kepon85 ?
Hi there, can you please post your question in https://help.nextcloud.com/c/dev/11 thats the better place for this. Thanks!
It's rather than a bug, no?
Did you find any solution for this?
If you do an unshare first and the share, the permissions will be set correctly. If you just re-share an existing share the permissions will stay as set the first time without returning an error. Observed in NC 21.0.2
I had the same issue with different versions of nextcloud.
As a workaround, I'm creating the share and set the permissions with Update Share PUT command afterwards. But you have to get the share_id from the output of the creation command
That works fine. I hope this helps some of you!
Not solved yet, hello? Why closed?
but the ocs update api is also not working
FTR, there is a new version of this bug report: #32611