0
votes

Using graph explorer, I want to get data from Excel file from SharePoint site

From Onedrive (for business) this works: graph.microsoft.com/beta/me/drive/root:/Map1.xlsx:/workbook/worksheets

From SharePoint site doesn't: graph.microsoft.com/beta/sharepoint:/MyFabulousSite/MyDocLib/Map1.xlsx:/Workbook/worksheets Response:

Status Code: 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"
        }
    }
}

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.

Update:

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

1
All the access path looks right to me. Quick question: are you able to simply do file metadata GET (that is leave out /workbook/... segments out) on the non-root sites?Sudhi Ramamurthy
Checking to see if all paths have been enabled for Excel API access... will circle back.Sudhi Ramamurthy
Omitting /workbook/... does result in proper responsesmarkbeij
Looks like it is a bug. We'll get this correctedSudhi Ramamurthy

1 Answers

2
votes

There are couple of issues as far as I see.

  1. GET /sharePoint/sites only returns the default site. So you have to do an additional call to get to the site in question using sharePoint/sites/{id}.
  2. When you use full SharePoint based "path" in the URL, the Excel API path /workbook is not being recognized.

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.

Workaround:

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"
}

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

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.