WebDAV and SEARCH

Did anyone get the SEARCH “call” working with WebDAV.

I’ve tried all the different endpoints I can think of and using just about any format of the request I can think of, but I still get 500 errors. I saw a discussion somewhere about the documentation not being correct about the URL/URI, etc. but that it had since been fixed.

The actual data I send along with the request looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
  <d:basicsearch>
    <d:select>
      <d:prop>
        <oc:fileid/>
        <d:displayname/>
        <d:getcontenttype/>
      </d:prop>
    </d:select>
    <d:from>
      <d:scope>
        <d:href>/files</d:href>
        <d:depth>infinity</d:depth>
      </d:scope>
    </d:from>
    <d:where>
      <d:like>
        <d:literal>Next%</d:literal>
      </d:like>
    </d:where>
  </d:basicsearch>
</d:searchrequest>

I’ve tried using <d:href>/files</user/d:href> as well, but with the same result.

I’m obviously doing something wrong, but what? :slight_smile:

-joho

https://docs.nextcloud.com/server/18/developer_manual/client_apis/WebDAV/search.html

Worked for me some weeks ago.

1 Like

Thanks. I’ve tried that (obviously, it’s “in the manual” :slight_smile:), but I’ll just have to tinker around some more I guess. Maybe NC is sensitive about orderby not being present in my request. In the example it’s empty, so maybe it’s still required.

OK … this works. So I was missing a few pieces.

<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
  <d:basicsearch>
    <d:select>
      <d:prop>
        <oc:fileid/>
        <d:displayname/>
        <d:getcontenttype/>
      </d:prop>
    </d:select>
    <d:from>
      <d:scope>
        <d:href>/files/devtest/</d:href>
        <d:depth>infinity</d:depth>
      </d:scope>
    </d:from>
    <d:where>
      <d:like>
        <d:prop>
          <d:displayname/>
        </d:prop>
        <d:literal>Nextcloud%</d:literal>
      </d:like>
    </d:where>
    <d:orderby/>
  </d:basicsearch>
</d:searchrequest>