【问题标题】:How can I access the UniqueId of a folder using CSOM against Sharepoint 2013如何针对 Sharepoint 2013 使用 CSOM 访问文件夹的 UniqueId
【发布时间】:2017-05-15 16:57:23
【问题描述】:

在针对 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年有没有办法找回这个字段?

【问题讨论】:

    标签: sharepoint sharepoint-2013 sharepoint-online csom


    【解决方案1】:

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

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

    “GUIDYOUNEED”等于文件夹的 UniqueId。

    【讨论】:

    • 非常感谢,这似乎可以让我使用 CSOM 16.1 访问 SP 在线和 2013 上的唯一 ID。谢谢
    【解决方案2】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2013-06-08
      • 1970-01-01
      • 1970-01-01
      • 2017-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多