Error using webDAV Search

The issue you are facing: Getting the error Principal with name myFolder not found when using WebDAV Search.

Is this the first time you’ve seen this error? : Yes, but also the first time i try this function.

Steps to replicate it:

  1. Run the command
curl -u myUser:myPass 'https://nextcloud.customExample.com/remote.php/dav/' -X SEARCH -u myUser:myPass -H "content-Type: text/xml" --data '<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
    <d:basicsearch>
        <d:select>
            <d:prop>
                <d:displayname/>
            </d:prop>
        </d:select>
        <d:from>
            <d:scope>
                <d:href>/files/myFolder/myFile.apk</d:href>
                <d:depth>infinity</d:depth>
            </d:scope>
        </d:from>
        <d:where>
            <d:like>
                <d:prop>
                    <d:getcontenttype/>
                </d:prop>
                <d:literal>text/%</d:literal>
            </d:like>
        </d:where>
        <d:orderby>
            <d:prop>
                <oc:size/>
            </d:prop>
            <d:ascending/>
        </d:orderby>
    </d:basicsearch>
</d:searchrequest>'

The output of your Nextcloud log in Admin > Logging:

<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Sabre\DAV\Exception\NotFound</s:exception>
  <s:message>Principal with name myFolder not found</s:message>
</d:error>

The folder myFolder is, as I see, in the root of my Nextcloud. I don’t know if I need something more to add before it (as I added “files”).

My objective is to check if a file exists in the nextcloud. I’ve asked for this in this forum before, but I didn’t get any answer so I’m still stuck in this step (now I’m trying to check it using the webDav search).

Thanks.

After all I’ve found an easier way to check if a file exists:

url='http://example.com/index.html'
if ( curl -o/dev/null -sfI "$url" ); then
  echo "URL exists"
else
  echo "URL does not exist"
fi

To that curl command you can add the --user parameter if you need authentication.

I’ve found it here.

I’ve been searching for it a couple of days now and I’ve found it easy to resolve for a person with knowledge in this topic. Despite this I have not received an answer in any of the questions I have published in this forum, which leads me to think that this community is not very useful, at least for new users (who in principle will be the ones who need more help).