[Owncloud] Sharing files/folders via REST API in oc6
Vincent H
vincenth76 at live.nl
Wed Nov 6 15:56:16 UTC 2013
Hi,
Sending this to the mailinglist on advice of Rancor:
After trying to use the sharing api (via REST) in oc5 (http://forum.owncloud.org/viewtopic.php?f=23&t=17952), which doesn't work, I am now trying it in oc6 beta 2. I think it is still a little buggy and I guess it has something to do with the user session/credentials.
Environment:LocalServer:Windows 7 with WAMPDatabase: Mysql 5.5.24Client: Firefox (and others)OC-Version: 6 beta2PHP-Version: Apache/2.2.22 (Win64) PHP/5.4.3
I installed oc6 (beta 2) out of the box and created a share on a folder. After that, I tried the following scenarios:
1. Not logged in to oc6 via the browser (so no existing session)Call REST GET url: http://localhost/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares Credentials are asked by the browser (http basic authentication), after filling them in (correctly), the request breaks with Fatal error: Call to a member function getRoot() on a non-object in \owncloud\lib\private\files\filesystem.php on line 407
2. Logged in normally to oc6 via the browser and open a new tab and op en the REST url againCall REST GET url: http://localhost/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares This works, I get a nice XML message with all info about existing shares
3. Now refresh the page with the REST GET url at step 2.Now the page breaks with Fatal error: Call to a member function getRoot() on a non-object in \owncloud\lib\private\files\filesystem.php on line 407
If the page with the normal login to oc6 is refreshed a redirect is done to the login screen. After a new login and refreshing the shares url, this works again exactly 1 time.
It look like the REST call does something with the user session or something.
My goal is to share a folder from Java code, running it from there (via restlet) always results in the same Fatal error.
ClientResource resource = new ClientResource("http://localhost/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares");// Send an authenticated request using the Basic authentication scheme.resource.setChallengeResponse(ChallengeScheme.HTTP_BASIC, "admin", "welcome1");// Send the requestresource.get();Representation content = resource.get();System.out.println(content.getText());
When trying all the above steps with a basic call: http://localhost/owncloud/ocs/v1.php/cloud/user (also requires a user session, thus a login) all works out fine, including the call from Java code.
Any ideas? Or maybe another approach to achieve this via Java code?
Kind regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/owncloud/attachments/20131106/757152e4/attachment.html>
More information about the Owncloud
mailing list