如何使用CSOM针对Sharepoint 2013

时间:2017-05-12 13:53:04

标签: sharepoint sharepoint-2013 sharepoint-online csom

在针对SharePoint Online的CSOM 16.1中使用以下代码,我可以检索文件夹列表:

var folderList = string.IsNullOrEmpty(parentRelativeUrl)
? sharePointContext.Web.Folders
: sharePointContext.Web.GetFolderByServerRelativeUrl(parentRelativeUrl).Folders;

sharePointContext.Load(folderList, items => items.Include(
item => item.Folders, 
item => item.Files,
item => item.Name, 
item => item.ServerRelativeUrl, 
item => item.Properties, 
item => item.UniqueId));

sharePointContext.ExecuteQuery();

当针对2013年内部版本的SharePoint运行时,我的绊脚石似乎是在UniqueId字段周围。我得到的错误是:

  

字段或属性“UniqueId”不存在。

然后我尝试将我的CSOM版本降级到2013,我可以看到Folder类不包含UniqueId字段。

有没有办法在2013年检索此字段?

2 个答案:

答案 0 :(得分:1)

对于您目前的情况,我建议您查看可用于SharePoint 2013的ClientObject.Path属性。不需要检索它,因为它是一个内部属性,它将由API组成。对于我的测试,它包含以下值:

Console.WriteLine(folder.Path);
"GUID|GUID:site:GUID:web:GUID:folder:GUIDYOUNEED"

'GUIDYOUNEED'等于文件夹的UniqueId。

答案 1 :(得分:0)

Item.Id会帮助你..你只能选择可用的变量。你输入物品的那一刻。帮助将为您提供与项目关联的操作和变量列表,您必须选择" id"获取项目的uniqueId 要获取列表或文档库的ID,您可以使用方法" GetListByTitle"。

 List doc = web.Lists.GetByTitle("Documents");
        clientContext.Load(doc);
clientContent.ExecuteQuery();

doc.id将为您提供文档库的唯一ID。

相关问题