使用 Microsoft Graph API 从 Sharepoint 站点提取 Excel.xlsx 工作簿 [英] Pulling Excel.xlsx workbook from Sharepoint site using Microsoft Graph API
问题描述
如标题所述,我一直在尝试使用 Microsoft Graph API 从我们公司的 Sharepoint 站点中提取 Excel 工作簿.我能够检索文件的元数据,但是当我将 /workbook/
段添加到 URL 时,我收到以下错误:
As stated in the title, I've been trying to use the Microsoft Graph API to pull an Excel workbook from our company's Sharepoint site. I am able to retrieve the metadata for the file, but when I add the /workbook/
segment to the URL, I receive the below error:
{
"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"
}
}
}
获取文件元数据的成功调用如下所示:
Here is what the successful call getting the file metadata looks like:
https://graph.microsoft.com/v1.0/sites/{siteid}/lists/{listid}/items/273
这是我正在调用的返回上述错误的调用:
And here is the call I am making which returns the above error:
https://graph.microsoft.com/v1.0/sites/{siteid}/lists/{listid}/items/273/workbook/
我能够找到这个 stackoverflow 帖子讨论了一个类似的错误,但是那是几年前的事情,显然使用了 Graph API 的测试版,我无法使用该帖子中的建议获得更多信息.使用微软图形测试版从共享点站点获取工作簿
I was able to find this stackoverflow post discussing a similar error, however that was a couple of years ago, apparently using a beta version of the Graph API, and I was not able to get any farther using suggestions from that post. Get workbook from sharepoint site using microsoft graph beta
我正在根据阅读这两个 Microsoft 文档构建我的请求 URL:https://docs.microsoft.com/en-us/graph/api/resources/sharepoint?view=graph-rest-1.0https://docs.microsoft.com/en-us/graph/api/resources/excel?view=graph-rest-1.0
I am building my request URL based on reading these two Microsoft docs: 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 构建请求.
I don't think it's relevant, but I'm using C# and building the requests with Restsharp.
有没有人对此有任何见解?
谢谢!
Does anyone have any insight on this?
Thanks!
推荐答案
You can't use /workbook
against a ListItem
, it can only be used with a DriveItem
.
为此,您需要首先获取与 ListItem
关联的 DriveItem
:
In order to do that, you'll need to first obtain the DriveItem
associated with the ListItem
:
/v1.0/sites/{siteid}/lists/{listid}/items/273/driveitem/workbook
这篇关于使用 Microsoft Graph API 从 Sharepoint 站点提取 Excel.xlsx 工作簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!