使用Microsoft Graph API从Sharepoint网站提取Excel.xlsx工作簿 [英] Pulling Excel.xlsx workbook from Sharepoint site using Microsoft Graph API

查看:65
本文介绍了使用Microsoft Graph API从Sharepoint网站提取Excel.xlsx工作簿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如标题中所述,我一直在尝试使用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的Beta版,使用该帖子中的建议,我无法获得更多帮助.使用Microsoft图Beta从SharePoint网站获取工作簿

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.0 https://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!

推荐答案

您不能对 DriveItem .

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆