如何在不需要用户 ID 或用户主体名称的情况下查询 OneDrive 中的所有用户文件夹(通过 Microsoft Graph)?

问题描述 投票:0回答:1

我正在尝试创建对我们公司 OneDrive 的广泛搜索,但我需要在不针对特定用户的情况下这样做。我必须搜索文件以获取特定内容,因此我需要广撒网。

我有 2 个独立的 API 与 Sharepoint 和 OneDrive 集成。 我已经测试了 GET 和 POST 调用以查找位于我的个人 OneDrive 文件夹中的特定文件。

我创建了 3 个相同的 Excel 文件,但命名不同。

文件名 文件位置
测试文件 1 https://COMPANY.sharepoint.com/sites/SHAREPOINTSITE/Shared
测试文件 2 https://COMPANY.sharepoint.com/sites/SHAREPOINTSITE/Shared
测试文件 3 https://COMPANY.sharepoint.com/personal/EMPLOYEE_ID/documents/documents

只知道 searchQuery,我尝试了这个 POST 调用 https://graph.microsoft.com/v1.0/search/query 具有以下有效负载响应,但结果仅定位 Test File 1 测试文件 2.

{
  "requests": [
    {
      "entityTypes": [
        "driveItem"
      ],
      "query": {
        "queryString": "${(event.payload.request.email)!}"
      },
      "region": "US"
    }
  ]
}

知道 searchQueryuserPrincipalName,我能够成功执行此 GET 调用以在我的个人公司 OneDrive 上找到 测试文件 3

https://graph.microsoft.com/v1.0/users/{userPrincipalName}/drive/root/search(q='{searchQuery')?select=name,id,webUrl

有没有办法在没有 /users/{userPrincipalName/ 的情况下执行相同的功能?

干杯,

R

api microsoft-graph-api onedrive
1个回答
0
投票

列出具有已知路径而不是用户 ID 的 DriveItem 或文件夹的子项:

GET /drives/{drive-id}/root:/{path-relative-to-root}:/children

更多信息:https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http#list-children-of-a-driveitem -有已知路径

希望这有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.