使用Microsoft Graph Beta从Sharepoint网站获取工作簿 [英] Get workbook from sharepoint site using microsoft graph beta
问题描述
使用图形浏览器,我想从SharePoint网站的Excel文件中获取数据
Using graph explorer, I want to get data from Excel file from SharePoint site
在Onedrive(适用于企业)中,此方法有效: graph.microsoft.com/beta/me/drive/root:/Map1.xlsx:/workbook/worksheets
From Onedrive (for business) this works: graph.microsoft.com/beta/me/drive/root:/Map1.xlsx:/workbook/worksheets
从SharePoint网站没有: graph.microsoft.com/beta/sharepoint:/MyFabulousSite/MyDocLib/Map1.xlsx:/Workbook/worksheets 响应:
From SharePoint site doesn't: graph.microsoft.com/beta/sharepoint:/MyFabulousSite/MyDocLib/Map1.xlsx:/Workbook/worksheets Response:
状态码:400
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'Workbook'.",
"innerError": {
"request-id": "160a545b-66b8-44fc-92b7-f2b327824b84",
"date": "2017-01-25T16:20:02"
}
}
}
也尝试过此方法,但也不起作用: graph.microsoft.com/beta/sharePoint/sites/ce33044e-6360-4630-9c5f-afad46f88333,cb1e4d7e-24be-433c-a874-12551cdd3348/drives/b!工作簿/工作表 响应:
Tried this as well, didn't work either: graph.microsoft.com/beta/sharePoint/sites/ce33044e-6360-4630-9c5f-afad46f88333,cb1e4d7e-24be-433c-a874-12551cdd3348/drives/b!TBQzzmBjMEacX6-tRviDM3FNHsu-JxxDqHQSVRzdM0hfFOUPQwasQb407ORQaT2q/root:/Map1.xlsx:/workbook/worksheets Response:
Status Code: 500
{
"error": {
"code": "-1, Microsoft.SharePoint.Client.UnknownError",
"message": "Onbekende fout",
"innerError": {
"request-id": "cec7663e-b708-4887-8d82-87d59fb15a2b",
"date": "2017-01-25T16:16:58"
}
}
}
猜猜我正在处理上一个请求,但仍然无法弄清细节.
Guess I'm closer using the last request, but still can't figure out the details.
更新:
将我的Excel文件移动到默认库的根站点中,我可以使用以下URL请求工作表: graph.microsoft.com/beta/sharePoint/site/drive/root:/Test.xlsx:/workbook/worksheets
Moving my Excel file to the root site in the default library, I'm able to request the worksheets using the following url: graph.microsoft.com/beta/sharePoint/site/drive/root:/Test.xlsx:/workbook/worksheets
推荐答案
据我所知,有几个问题.
There are couple of issues as far as I see.
- GET/sharePoint/sites仅返回默认站点.因此,您必须使用sharePoint/sites/{id}进行额外的呼叫才能进入有问题的站点.
- 当您在URL中使用完整的基于SharePoint的路径"时,无法识别Excel API路径/工作簿.
因此,作为解决方法,您必须浏览站点ID并在URL中进行驱动.在问题解决之前,您不能使用完整的站点Sharepoint路径来获取Excel文件并使用Excel API.
So, as a workaround you have to navigate through the site id and drive in the URL. Until the issue is fixed, you can't use the full site Sharepoint path to get to the Excel file and use Excel API.
解决方法:
第1期.您必须首先使用GET /sharePoint:/{path}:/
,其中{path}是站点(而不是文件或文件夹)的路径,并获取站点id
属性.
示例:
For Issue #1. You'd have to first use GET /sharePoint:/{path}:/
where {path} is the path to the site (not the file or folder) and get the site id
property.
Example:
GET https://graph.microsoft.com/beta/sharepoint:/exceltest:/?$select=id
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#baseItem",
"@odata.type": "#microsoft.graph.site",
"id": "48d4a189-be5d-497a-9a6d-b971db377a5c,3a201b6c-798f-4e6a-a805-9e67fdf1c8ce"
}
对于#2.现在,使用以下方法之一使用返回的id
转到文件所在的驱动器:
For #2. Now use the id
being returned to go to the drive where the file is located by using one of the following:
GET /sharePoint/sites/{id}/drive/root/items/{fileId}/workbook
GET /sharePoint/sites/{id}/drive/root:/{file-path}:/workbook
GET /sharePoint/sites/{id}/drives/{driveId}/root/items/{fileId}/workbook
GET /sharePoint/sites/{id}/drives/{driveId}/root:/{file-path}:/workbook
我可以使用我的开发者租户通过此替代方法访问Excel API.如果这不适合您,请告诉我.
I'm able to access Excel API with this workaround using my developer tenant. Please let me know if this doesn't work for you.
这篇关于使用Microsoft Graph Beta从Sharepoint网站获取工作簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!