WebDav HttpRequest Message for COPY. Is it well formed?

By : August
Source: Stackoverflow.com
Question!

Passing the below httprequest message to perform a COPY of a file on a WebDavServer returns a 'Bad Request' response message. I am unable to figure out if something is missing or given wrong in the request message.

HttpRequest Message:

{Method: COPY, RequestUri: 'https://testaddress.de:8000/Test/TextDoc.txt',
 Version: 1.1, Content: System.Net.Http.ByteArrayContent, Headers:
{
  Connection: Keep-Alive
  User-Agent: WebDAVClient/1.0.0.0
  Destination: file:///C:/Users/user/TestCenter/Scan/TextDoc.txt
  Content-Type: text/xml
}}

And the response is:

{StatusCode: 400, ReasonPhrase: 'Bad Request', 
 Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
  Persistent-Auth: true
  Date: Thu, 05 Nov 2015 15:05:14 GMT
  Server: Microsoft-IIS/8.5
  X-Powered-By: ASP.NET
  Content-Length: 24
  Content-Type: text/html
}}

Would appreciate if someone can point me in the right direction.

UPDATE It has been pointed out to me that COPY works only if the destination is on the same server, not if the destination is a path in your local system. If copying a remote file to a local location, you need to use a GET request and handle writing the data to the local path with the response stream. Thanks to @Julian Reschke and @Brian Warshaw

By : August


Answers

If you're trying to copy a remote file to a local location, you need to use a GET request and handle writing the data to the local path with the response stream.



This video can help you solving your question :)
By: admin