An API that connects multiple Microsoft services, enabling data access and automation across platforms
Microsoft Graph API returns stale data from Sharepoint Excel even after days. Tried 3 approaches as below to resolve the issue, but none worked
Issue Summary
We are using Microsoft Graph API to read data from a Sharepoint Excel file that is populated by Microsoft Forms.
However:
- The latest form submissions are not returned by the Graph API even after days
- The latest data becomes visible only after manually opening the Sharepoint Excel file
- This indicates a potential data synchronization or materialization issue between Microsoft Forms, Excel, and the Graph API
Resolution Approaches Attempted
The three approaches attempted were as below but none returned the latest Microsoft Forms submissions:
- Reading data from the Excel table instead of usedRange
- Programmatically opening and recalculating the workbook using a Graph API session, and
- Forcing a refresh via a write operation
Approach 1: Read Table Instead of usedRange
Objective
Use table-based reads since Microsoft Forms writes into an Excel table.
Implementation
GET https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/xxx/workbook/tables
GET https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/xxx/workbook/tables('{table-id}')/rows
Outcome
Table detected successfully (OfficeForms.Table)
Historical data is returned correctly
Latest form submissions are not returned
Approach 2: Workbook Session and Recalculation
The Steps 1 and 2 below were to programatically open the Sharepoint Excel, which it did, as the screenshot below
Step 1: Create Session
This simi
POST https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/xxx/workbook/createSession Content-Type: application/json
Request Body: { "persistChanges": true }
Step 2: Refresh Session
POST https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/xxx/workbook/refreshSession Header: workbook-session-id: ${workbook-session-id}
Step 3: Force Recalculation
POST https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/xxx/workbook/application/calculate Header: workbook-session-id: ${workbook-session-id}
Step 4: Read Data
GET https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/xxx/workbook/worksheets('Sheet1')/usedRange Header: workbook-session-id: ${workbook-session-id}
Outcome
Session creation is successful
Recalculation executes without error
Data retrieval works
Latest Microsoft Forms submissions are still not returned
Approach 3: Force Workbook Update via Write Operation
Objective
Trigger Excel internal refresh by performing a write operation
The programatic write operation succeeded as the below screenshot:
Implementation
PATCH https://graph.microsoft.com/v1.0/sites/xxx.sharepoint.com/xxx/workbook/worksheets('Sheet1')/range(address='Z1') { "values": [["Id"]] }
Outcome
Write operation succeeds
Workbook updates correctly
Latest form submissions still not visible via Graph API
Observed Behaviour
Microsoft Forms shows latest submissions immediately
Excel displays latest data when opened manually
Graph API does not return latest data until Excel file is opened
Opening the Excel file manually appears to trigger synchronization or materialization, after which the Graph API starts returning the expected data.