web-servicessharepointmovedocument-library

How to move document to different folder in SharePoint library with web services


I am desperately trying to move a document in a document library from one folder to another (yes, within the same library). All this is needed to be done through web services.

I am using UpdateListItems method with batching XML like this:

<Batch>
 <Method ID="1" Cmd="Update">
    <Field Name="ID">14</Field>
    <Field Name="ServerUrl">personal/blabla/Documents/CT-5/image.jpg</Field>
 </Method>
</Batch>

I have tried updating various fields instead of ServerUrl above - none with luck...

Thanks for any hints...


Solution

  • So eventually I found a way to get around this by using WebDAV. And sorry the question was posed incorrectly - I really did not need web services, rather whatever was available for me to use from a remote ASP.NET site. Here's the (simple) code to have a file moved:

    WebRequest lRequest = WebRequest.Create(sourceUrl);
    lRequest.Credentials = CredentialCache.DefaultCredentials;
    lRequest.Method = "MOVE";
    
    lRequest.Headers.Add("Destination", targetUrl);
    var lResponse = lRequest.GetResponse();