views:

2206

answers:

3

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...

+1  A: 

I don;t think this is possible with the out of the box web services. Yould write your own web service though and deploy that to sharepoint.

What's also a possibility is to use 2 web services: the copy web service and the lists web service. First do a copy, then use the Lists service to delete the original.

Colin
Although it is not what I wanted to hear obviously it looks like the reality... :-O
Rashack
+1  A: 

Yes, use the Copy Web Service as Colin suggests. It is the only way with the OOB Web services. But just be aware that you will lose all author and date information as well as any version history. The Copy WS does not preserve this information.

If this is a show stopper, you might want to take a look at CopyMove for SharePoint. It also ships with a Web service that allows you to copy or move documents, items and folders without loss of any metadata.

Lars Fastrup
+1  A: 

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();
Rashack