Update share by API don't work

10
hosting

#1

owc: 10.0.7

I try to do:

curl --user XXX:XXX “https://www.mydomain.com/ocs/v1.php/apps/files_sharing/api/v1/shares/1” --request PUT --data ‘name=MY%20NEW%20NAME’

and I always receive:

<?xml version="1.0"?> failure 400 Wrong or no update parameter given

the share id exist. I would to change the name of the share folder.
thanks


#2

I forsed the file Share20OCS.php to line 658, so the execution pass into “if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {”,
but despite this, the XML response correct:

<?xml version="1.0"?>

< ocs>
< meta>
< status>ok</ status>
< statuscode>100</ statuscode>
< message/>
</ meta>
< data>

but the share folder always have same name, it isn’t changed.


#3

Fresh 10.0.7 installation with the default configuration works for me:

$ curl -X PUT -u admin:Password --data 'name=MY%20NEW%20NAME' http://server:port/ocs/v1.php/apps/files_sharing/api/v1/shares/1

<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>100</statuscode>
  <message/>
 </meta>
 <data>
  <id>1</id>
  <share_type>3</share_type>
  <uid_owner>admin</uid_owner>
  <displayname_owner>admin</displayname_owner>
  <permissions>1</permissions>
  <stime>1527700524</stime>
  <parent/>
  <expiration/>
  <token>W7Xm8F5XeVdTGfx</token>
  <uid_file_owner>admin</uid_file_owner>
  <displayname_file_owner>admin</displayname_file_owner>
  <path>/giphy.gif</path>
  <item_type>file</item_type>
  <mimetype>image/gif</mimetype>
  <storage_id>home::admin</storage_id>
  <storage>1</storage>
  <item_source>16</item_source>
  <file_source>16</file_source>
  <file_parent>3</file_parent>
  <file_target>/giphy.gif</file_target>
  <share_with/>
  <share_with_displayname/>
  <name>MY NEW NAME</name>
  <url>http://server:port/index.php/s/W7Xm8F5XeVdTGfx</url>
  <mail_send>0</mail_send>
 </data>
</ocs>

If you’ve modified the default configuration for sharing, a screenshot (if possible) would help to check in similar conditions.


#4

I don’t change any configuration, I updated Share20OCS.php but only for a tried, now I put everything in place.
Also me the result is as you, only the share_type is 0 and not 3 (it’s for this I forsed the file Share20OCS.php).

<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>100</statuscode>
  <message/>
 </meta>
 <data>
  <id>1</id>
  <share_type>0</share_type>
  <uid_owner>administrator</uid_owner>
  <displayname_owner>Admin</displayname_owner>
  <permissions>31</permissions>
  <stime>1461241225</stime>
  <parent/>
  <expiration/>
  <token/>
  <uid_file_owner>administrator</uid_file_owner>
  <displayname_file_owner>Admin</displayname_file_owner>
  <path>/try/MY OLD NAME</path>
  <item_type>folder</item_type>
  <mimetype>httpd/unix-directory</mimetype>
  <storage_id>home::administrator</storage_id>
  <storage>1</storage>
  <item_source>20</item_source>
  <file_source>20</file_source>
  <file_parent>12</file_parent>
  <file_target>/MY NEW NAME</file_target>
  <share_with>bruno.rossi</share_with>
  <share_with_displayname>Bruno Rossi</share_with_displayname>
  <share_with_additional_info/>
  <mail_send>0</mail_send>
 </data>

but in web browser and table oc_share I see MY OLD NAM, why?
thanks


#5

The names are only applied for the links as is shown in the web UI. Shares with users or groups don’t have names.
What you’re trying to do is to rename the file. This is part of the wevDAV API not sharing.


#6

But no, the share is (by /ocs/v1.php/apps/files_sharing/api/v1/shares):

[0] => SimpleXMLElement Object
(
[id] => 1490
[share_type] => 0
[uid_owner] => administrator
[displayname_owner] => Admin
[permissions] => 31
[stime] => 1470834860
[parent] => SimpleXMLElement Object
(
)

                                [expiration] => SimpleXMLElement Object
                                    (
                                    )

                                [token] => SimpleXMLElement Object
                                    (
                                    )

                                [uid_file_owner] => administrator
                                [displayname_file_owner] => Admin
                                [path] => /PATH/MY NEW NAME
                                [item_type] => folder
                                [mimetype] => httpd/unix-directory
                                [storage_id] => home::administrator
                                [storage] => 1
                                [item_source] => 3328
                                [file_source] => 3328
                                [file_parent] => 3325
                                [file_target] => /MY OLD NAME
                                [share_with] => mario.rossi
                                [share_with_displayname] => mario rossi
                                [share_with_additional_info] => SimpleXMLElement Object
                                    (
                                    )

                                [mail_send] => 0
                            )

I done the rename, in fact in path there is the new name, while in file_target I see the old name.