curlwebdavpropfind

How do I send this specific curl WebDAV PROPFIND command from a terminal?


At this site I found this curl command:

curl -i -X PROPFIND http://example.com/webdav/ --upload-file - -H "Depth: 1" <<end
<?xml version="1.0"?>
<a:propfind xmlns:a="DAV:">
<a:prop><a:resourcetype/></a:prop>
</a:propfind>
end

I change http://example.com/webdav/ to http://localhost/uploads, where localhost is a wamp64 server and uploads is a WebDav directory. Many of the curl commands at the above site were similarly tested and work fine when issued from a CMD prompt on my local computer. However I cannot get the PROPFIND command to work. Pasting directly into the cmd prompt results in Bad request error. I then tried:

curl -i -X PROPFIND http://example.com/webdav/ --upload-file - -H "Depth: 1"

In the cmd prompt, and this resulted in the server response "HTTP 1.1 100 Continue" followed by a blank line and blinking cursor. I have researched the 100 Continue issue as it pertains to curl and have only found discussions and methods of avoiding getting that response, but no indication of how to send the data the server is expecting.

I am assuming that the "<<end <a:propfind xmlns:a="DAV:"> <a:prop <a:resourcetype/></a:prop> </a:propfind> end" constitutes the 100 Continue data that the server is waiting for, BUT HOW DO I SEND IT?


Solution

  • Are you on windows terminal, right? The command that you tried is for Linux/UNIX. There is a difference.

    On Win you can install Git and it also will install bash terminal which is the same as in linux.

    Anyway the command that you tried sends a PROPFIND request with a body that contains XML with a list of properties that you wish to receive. And the list contains only one property resourcetype which is a content type like text/plain. For sure you wish to get all fields like name and size.

    You can simply omit the body then it will return all default props:

    curl -v -i -X PROPFIND example.com/webdav -H "Depth: 1" 
    

    The Depth: 1 header means to list the folder only but not it's subfolders.

    Here I collected samples WebDAV with curl for scripts and command line