Home » excel » json – Stale data from Microsoft Graph and Excel API

json – Stale data from Microsoft Graph and Excel API

Posted by: admin April 16, 2020 Leave a comment

Questions:

We’re using the Microsoft Graph .NET Client Library to send requests to the Excel API in order to read or write to Excel files in Office365. We have noticed that the data that we get back from the API is sometimes stale.

For instance, if we add a row to an Excel file, and then immediately read all rows from the same file, even if the add request succeeds, the row will still be missing from the data that we read back. If we wait for a few seconds, the row will show up. This problem does not reproduce consistently, and the delay time varies from less than a second to sometimes tens of seconds. The same problem occurs in update or delete operations as well.

Based on this, we speculate that behind the API, data takes a significant amount of time to propagate across all of Microsoft’s servers, and if our requests are not always routed to the same server, we will occasionally hit a server that does not have the latest data.

Could someone who is working on either the Microsoft Graph API or the Excel API verify this guess? We understand that as Microsoft transitions from shipping packaged software to building cloud services, there will be problems and challenges, so we don’t expect an immediate solution. However, since our business depends greatly on this API, if there is a known problem, please let us know so that at least we can try to find a workaround on our end.

Any response would be greatly appreciated. Thank you in advance.

How to&Answers:

Please check
https://dev.office.com/blogs/power-your-apps-with-the-new-excel-rest-api

Copied from the above URL:

Note: Any request that modifies the workbook should be performed in a
persisted session. Find more details on how to create a persisted
session in our documentation.

Create a persisted session

POST .../workbook/CreateSession
content-type: Application/Json 
authorization: Bearer {access-token} 
{ "persistChanges": true }

Response
HTTP code: 201, Created
content-type: application/json;odata.metadata  
{  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.sessionInfo", "id": "{session-id}",  "persistChanges": true}

Usage The session ID returned from the CreateSession call is then
passed as a header on subsequent API requests using the
workbook-session-id HTTP header.

GET .../workbook/Worksheets
authorization: Bearer {access-token} 
workbook-session-id: {session-id}