I would like to read some folder- and file-properties from sharepoint 2010 server. The most important property is the UniqueId. Is there any possibility to read that property?
I tried with csom (Microsoft.SharePoint.Client.dll). This works fine with the code below for sharepoint 2013 and above. It works for sharepoint online and sharepoint server. The problem is for sharepoint 2010 server where I need to read. An exception occurs like "The Field or Property UniqueId is not available". The "ListItemAllFields" is not available either. I read many posts but I could not found a solution.
I could figure out that there would be normaly 3 solutions for it:
1. csom (Would be the best solution and works perfect for 2013 and above -> no solution found for 2010 server)
2. ssom (Works only when everything is on the same server -> is no solution for me because the application where I need to read is not on the same server like sharepoint)
3. webservices (I could not found a matching solution with webservices)
I read about Caml query and found something like
Here the code which works fine for sharepoint 2013 and above but did not work for sharepoint 2010 server:
The expected result would be retrieving the UniqueId and ListItemAllFields from sharepoint 2010 server.
The actual result is: "The Field or Property UniqueId is not available".
I tried with csom (Microsoft.SharePoint.Client.dll). This works fine with the code below for sharepoint 2013 and above. It works for sharepoint online and sharepoint server. The problem is for sharepoint 2010 server where I need to read. An exception occurs like "The Field or Property UniqueId is not available". The "ListItemAllFields" is not available either. I read many posts but I could not found a solution.
I could figure out that there would be normaly 3 solutions for it:
1. csom (Would be the best solution and works perfect for 2013 and above -> no solution found for 2010 server)
2. ssom (Works only when everything is on the same server -> is no solution for me because the application where I need to read is not on the same server like sharepoint)
3. webservices (I could not found a matching solution with webservices)
I read about Caml query and found something like
<FieldRef Name='UniqueId'/>but I don't know how to use it and I don't know if reading UniqueId even is possible with it.
Here the code which works fine for sharepoint 2013 and above but did not work for sharepoint 2010 server:
public string GetChilds(ClientContext clientContext, string relativeUrl) { SpFolder folder=clientContext.Web.GetFolderByServerRelativeUrl(relativeUrl); clientContext.Load(folder, item => item.Name, item => item.UniqueId, item => item.ServerRelativeUrl ); clientContext.Load(folder.Folders, items => items.Include( item => item.Name, item => item.UniqueId, item => item.ServerRelativeUrl, item => item.TimeLastModified, item => item.TimeCreated, item => item.ListItemAllFields["Author"], item => item.ListItemAllFields["Editor"])); clientContext.Load(folder.Files, items => items.Include( item => item.Name, item => item.UniqueId, item => item.ServerRelativeUrl, item => item.TimeLastModified, item => item.TimeCreated, item => item.ListItemAllFields["Author"], item => item.ListItemAllFields["Editor"], item => item.ListItemAllFields["File_x0020_Size"])); clientContext.ExecuteQueryWithIncrementalRetry(EXECUTEQUERY_RETRYCOUNT, EXECUTEQUERY_DELAY); string result = ""; result += "Parent Name:" + folder.Name + ","; result += "Parent UniqeId:" + folder.UniqueId.ToString() + ","; result += "Parent ServerRelativeUrl:" + folder.ServerRelativeUrl + ","; if (folder.Folders != null) { foreach (SpFolder subFolder in folder.Folders) { result += "Name:" + subFolder.Name + ","; result += "UniqueId:" + subFolder.UniqueId.ToString() + ","; //... } } if (folder.Files != null) { foreach (SpFile file in folder.Files) { result += "Name:" + file.Name + ","; result += "UniqueId:" + file.UniqueId.ToString() + ","; //... } } return result; }
The expected result would be retrieving the UniqueId and ListItemAllFields from sharepoint 2010 server.
The actual result is: "The Field or Property UniqueId is not available".