R – Download specific version of a file from SharePoint using web services

sharepointsharepoint-2007web services

Can someone provide a sample for downloading a specific version of a file from SharePoint using web services? Normally I would get the file with the Copy Web Service (…/_vti_bin/copy.asmx). But I don't really know how to specify a version.

Regards

Anton Kalcik

Best Answer

You can use the Versions web service to get which versions exist for a File

The GetVersions method will give you an xml like this:

<results xmlns="http://schemas.microsoft.com/sharepoint/soap/">
   <list id="{26E516B0-8241-4B97-984D-000000000000}" />
      <versioning enabled="1" />
   <settings url="http://Server_Name/Site_Name/_layouts/
         1033/LstSetng.aspx?
      List={26E516B0-8241-4B97-984D-000000000000}" />
   <result version="@4" url="http://Server_Name/Site_Name/
         Shared Documents/File_Name.doc" 
      created="6/7/2003 5:55 PM" createdBy="DOMAIN\User" size="19968" 
         comments="" />
   <result version="1" url="http://Server_Name/Site_Name/
         _vti_history/1/Shared Documents/File_Name.doc" 
      created="6/7/2003 5:49 PM" createdBy="DOMAIN\User" size="19968" 
         comments="" />
      .
      .
      .
</results>

You can then just use a HTTP GET request for the content of the "url" attribute of the "result" node for the right version

Related Topic