Office365 使用microsoft graph beta从sharepoint网站获取工作簿

Office365 使用microsoft graph beta从sharepoint网站获取工作簿,office365,microsoft-graph-api,Office365,Microsoft Graph Api,使用图形浏览器,我想从SharePoint网站的Excel文件中获取数据 从Onedrive(商务版)开始,这项工作: graph.microsoft.com/beta/me/drive/root:/Map1.xlsx:/workbook/worksheets “从SharePoint网站”不会: graph.microsoft.com/beta/sharepoint:/MyFabulousSite/MyDocLib/Map1.xlsx:/Workbook/worksheets 答复: Stat

使用图形浏览器,我想从SharePoint网站的Excel文件中获取数据

从Onedrive(商务版)开始,这项工作: graph.microsoft.com/beta/me/drive/root:/Map1.xlsx:/workbook/worksheets

“从SharePoint网站”不会: graph.microsoft.com/beta/sharepoint:/MyFabulousSite/MyDocLib/Map1.xlsx:/Workbook/worksheets 答复:

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"
        }
    }
}
状态代码: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!TBQZZMBJMEAC66-tRviDM3FNHsu-JxxDqHQSVRzdM0hfFOUPQwasQb407ORQaT2q/root:/Map1.xlsx:/工作簿/工作表 答复:

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"
        }
    }
}
我想我已经接近使用最后一个请求了,但仍然无法了解细节

更新:

将Excel文件移动到默认库中的根站点,我可以使用以下url请求工作表:
graph.microsoft.com/beta/sharePoint/site/drive/root:/Test.xlsx:/workbook/worksheets

就我所见,有几个问题

  • GET/sharePoint/sites仅返回默认站点。因此,您必须使用sharePoint/sites/{id}执行另一个调用才能访问相关站点
  • 在URL中使用基于SharePoint的完整“路径”时,无法识别Excel API路径/工作簿 因此,作为一种解决方法,您必须在URL中浏览站点id和驱动器。在问题解决之前,您无法使用完整的站点Sharepoint路径访问Excel文件并使用Excel API

    解决方法:

    第1期。您必须首先使用
    GET/sharePoint://{path}://
    其中{path}是指向站点(而不是文件或文件夹)的路径,并获取站点
    id
    属性。 例如:

    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
    通过以下操作之一转到文件所在的驱动器:

    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。如果这对你不起作用,请告诉我

    在我看来有两个问题

  • GET/sharePoint/sites仅返回默认站点。因此,您必须使用sharePoint/sites/{id}执行另一个调用才能访问相关站点
  • 在URL中使用基于SharePoint的完整“路径”时,无法识别Excel API路径/工作簿 因此,作为一种解决方法,您必须在URL中浏览站点id和驱动器。在问题解决之前,您无法使用完整的站点Sharepoint路径访问Excel文件并使用Excel API

    解决方法:

    第1期。您必须首先使用
    GET/sharePoint://{path}://
    其中{path}是指向站点(而不是文件或文件夹)的路径,并获取站点
    id
    属性。 例如:

    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
    通过以下操作之一转到文件所在的驱动器:

    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。如果这对你不起作用,请告诉我

    我觉得所有的通道都是对的。快速问题:您是否能够简单地在非根站点上获取文件元数据(即省略
    /workbook/…
    段)?检查是否已为Excel API访问启用所有路径。。。将返回。忽略/工作簿/。。。是否会导致正确的响应看起来像是一个bug。我们会纠正的,所有的通道看起来都对。快速问题:您是否能够简单地在非根站点上获取文件元数据(即省略
    /workbook/…
    段)?检查是否已为Excel API访问启用所有路径。。。将返回。忽略/工作簿/。。。是否会导致正确的响应看起来像是一个bug。我们会改正的