【问题标题】:Retrieving Custom Document Metadata from SharePoint using Microsoft Graph使用 Microsoft Graph 从 SharePoint 检索自定义文档元数据
【发布时间】:2020-06-22 23:15:10
【问题描述】:

我正在尝试使用 Microsoft Graph API 检索自定义文档元数据,但是当我指定所用构面的名称时,不会返回数据。

var items = graph.Drives[drive.Id].Search(q).Request().Top(num_results).Select("id,name,file,weburl,createdby,lastmodifiedby,createddatetime,lastmodifieddatetime,package,revision").GetAsync().GetAwaiter().GetResult();

上述使用的方面正在返回除包和修订之外的数据,这是我的共享点实例所独有的。

当我使用 Microsoft Graph API 进行搜索时,有什么方法可以返回这些列/构面的数据?

【问题讨论】:

    标签: sharepoint microsoft-graph-api sharepoint-online


    【解决方案1】:

    您可以通过将库视为list 而不是drive 来访问这些字段 - 您可以调用/v1.0/sites/FOO/lists/BAZ/items?expand=fields 而不是调用/v1.0/sites/FOO/drives/BAR/children

    给定一个驱动器 ID,您可以请求 https://graph.microsoft.com/v1.0/drives/DRIVE_ID/list 获取列表。

    【讨论】:

    • 这应该被标记为解决方案。我得到了所有元数据,包括分类数据。
    【解决方案2】:

    对于特定文档上的自定义文档元数据,请使用 Get list item 方法,其中 item-id 引用列表中的特定文档,如下所示:v1.0/sites/{site-id }/lists/{list-id}/items/{item-id} 文档: https://docs.microsoft.com/en-us/graph/api/listitem-get

    item-id 是此处记录的列表中的 GET 列表项方法返回的特定文档的 id: https://docs.microsoft.com/en-us/graph/api/list-get?view=graph-rest-1.0&tabs=http

    这会返回任何自定义的数据字段

    【讨论】:

      【解决方案3】:

      您可以尝试以下 API 来获取标签和元数据,通过我的测试,它现在不会返回自定义元数据:

      By the driveItem unique identifier using drive/items/{item-id}
      By file system path using /drive/root:/path/to/file
      
      GET /drives/{drive-id}/root/search(q='{search-text}')
      GET /groups/{group-id}/drive/root/search(q='{search-text}')
      GET /me/drive/root/search(q='{search-text}')
      GET /sites/{site-id}/drive/root/search(q='{search-text}')
      GET /users/{user-id}/drive/root/search(q='{search-text}')
      

      https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_search https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/driveitem

      如果您也无法通过 expand=fields 获取信息,建议您提交功能请求:https://officespdev.uservoice.com/

      【讨论】:

      • 我无法通过一个查询/搜索查询本身获取信息,但通过选择搜索文档所属的 SharePoint 列表信息,我能够获取列表和列表项 ID。然后使用这些来单独调用 graph 以检索丢失的文档属性。
      • 很多自定义元数据无法从上述api中获取,所以如果不起作用,只需提交功能请求或更改您的项目设计。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-25
      • 1970-01-01
      相关资源
      最近更新 更多