Using WebDAV to access Nextcloud resources is a pretty nice way to write integrations for Nextcloud. While adding support for Nextcloud file browsing in a service we’re constantly improving, I ran into a minor snag: How to format the WebDAV “SEARCH” request when interfacing with Nextcloud.
1. The example in the official documentation is correct. You just have to read it carefully. In particular, pay attention to this:
Search requests can be made by sending a SEARCH http request to https://cloud.example.com/remote.php/dav/ with a content type of text/xml and the query as xml in the request body.
2. Make sure you structure your XML data properly, in particular, you need to make sure you include a d:prop of which “field” you want your search data to be applied to.
<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
This would search for files beginning with Nextcloud and return fileid, displayname, and the content type; the search will be made in the folders that testuser has access to.
And that’s that.