Wednesday, March 25, 2015

Get data in a SharePoint list view in XML format

Here is a quick way to retrieve data displayed in a sharepoint list or document library view in XML format, use the list id, view id in following format

http://Server_Name/[sites/][Site_Name/]_vti_bin/owssvr.dll?XMLDATA=1&List={<List GUID>}&View={<View GUID>}&RowLimit=0&RootFolder=<URL Encoded Relative path of the folder>

The variables are
<Site URL>: normal URL of the web or subsite where your list or document library exists e.g. http://sharepoint/sites/hr

<List GUID>: GUID of the list e.g. 263FE49C-7FB3-4247-93CD-4AAB9770EF97
<View GUID>: GUID of the view in question 
<URL Encoded Relative path of the folder>: Relative of the folder inside list which you 
need to converted to XML e.g. %2fsites%2fHR%2fDocuments
Also refer to following post for more details about this command
https://msdn.microsoft.com/en-us/library/dd587743(v=office.11).aspx
If you need to export to excel, you can use 
http://Server_Name/[sites/][Site_Name/]_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=GUID&View=GUID&CacheControl=1
as explained in above microsoft help. Also, I have found out that this URL format works as well
http://Server_Name/[sites/][Site_Name/]_vti_bin/owssvr.dll?CS=65001&Using=_layouts/query.iqy&List=%7B<List GUID>%7D&View=%7B<View GUID>%7D&RootFolder=<URL Encoded Relative path of the folder>&CacheControl=1

To generate outlook calender events file replace Using=_layouts/query.iqy with Using=event.ics as explained here


No comments:

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...