How to read data from Microsoft Graph using a get request?

645 Views Asked by At

My goal is to read the data inside an Excel at azure with some get request. I am trying to get the JSON contain the information form one of my Excel files. I am using the "Excel: used range in worksheet", it can be found in the page "https://developer.microsoft.com/en-us/graph/graph-explorer". In the get query area it says the query is: https://graph.microsoft.com/v1.0/me/drive/items/{drive-item-id}/workbook/worksheets('Sheet1')/usedRange. After changing the {drive-item-id} and the Sheet1 for correct values it gives me an error or authentication:

{"error":{"code":"InvalidAuthenticationToken","message":"Access token is empty.","innerError":{"date":"2021-06-09T16:26:24","request-id":"60912689-40d7-4f84-ba3b-d2350d121044","client-request-id":"60912689-40d7-4f84-ba3b-d2350d121044"}}}

Is it possible to just add the access token to it and get all the data from the file? For example: https://graph.microsoft.com/v1.0/me/drive/items/{drive-item-id}/workbook/worksheets('Sheet1')/usedRange?token=12345678

1

There are 1 best solutions below

4
On

It is not possible to add the access token directly to the request URL, you need to add it to the request header as Authorization:Bearer <access token>(don't miss the space) when you call the API.

You can also call the API in the graph explorer, in it don't need to add the token manually, just sign the explorer and click Modify permissions to add Files.ReadWrite delegated permission, then you can call the API.

enter image description here