使用 Microsoft Graph API 从 Sharepoint 站点提取 Excel.xlsx 工作簿

Dav*_*vid 2 excel sharepoint microsoft-graph-api

如标题所述,我一直在尝试使用 Microsoft Graph API 从我们公司的 Sharepoint 站点中提取 Excel 工作簿。我能够检索文件的元数据,但是当我将/workbook/段添加到 URL 时,我收到以下错误:

{
  "error": {
    "code": "BadRequest",
    "message": "Resource not found for the segment 'workbook'.",
    "innerError": {
      "request-id": "bf41e41a-bc01-4c3b-b1d7-3125c4d48124",
      "date": "2019-04-10T16:29:07"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

这是获取文件元数据的成功调用的样子:

https://graph.microsoft.com/v1.0/sites/{siteid}/lists/{listid}/items/273
Run Code Online (Sandbox Code Playgroud)

这是我正在进行的调用,它返回上述错误:

https://graph.microsoft.com/v1.0/sites/{siteid}/lists/{listid}/items/273/workbook/
Run Code Online (Sandbox Code Playgroud)

我能够找到这个 stackoverflow 帖子讨论了一个类似的错误,但那是几年前,显然使用了 Graph API 的测试版,我无法使用该帖子中的建议获得更多信息。 使用 microsoft graph beta 从 sharepoint 站点获取工作簿

我正在根据阅读这两个 Microsoft 文档构建我的请求 URL:https : //docs.microsoft.com/en-us/graph/api/resources/sharepoint ? view = graph- rest- 1.0 https://docs.microsoft .com/en-us/graph/api/resources/excel?view=graph-rest-1.0

我认为这无关紧要,但我正在使用 C# 并使用 Restsharp 构建请求。

有没有人对此有任何见解?
谢谢!

Mar*_*eur 6

您不能/workbook对 a使用ListItem,它只能与 a 一起使用DriveItem

为了做到这一点,您需要首先获得与DriveItem关联的ListItem

/v1.0/sites/{siteid}/lists/{listid}/items/273/driveitem/workbook
Run Code Online (Sandbox Code Playgroud)

  • 恐怕这是多年在图元数据和细微差别方面的丰富经验。也就是说,我完全同意:https://github.com/microsoftgraph/microsoft-graph-docs/issues/4369 (2认同)