microsoftgraph / microsoftgraph/msgraph-sdk-dotnet
Workbook session not persisting changes
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 789
- Forks
- 264
- Avg merge
- 15h 17m
- Merged PRs (30d)
- 3
Description
Describe the bug
I am trying to update workbook table rows within a created session (passing 'workbook-session-id' in the header) to improve the performance of my code but no changes occur, either immediately after update call or on session close.
Using the graph API explorer seems to work (create session, update row with session id, close session), although the changes occur immediately after row update, rather than on session close. Not sure if this is expected behavior.
Although not related to this, but in pursuit of improving the performance of my code I tried to use batch requesting, with and without a session id, and this also didn't work.
Additionally, it seems lots of your example code is incorrect (e.g. Close session c# snippet).
Expected behavior
Workbook table Rows are updated when used with a session
How to reproduce
The following works when the code to add the session id to header is removed
var workbookFileDriveItem = await MsGraphHelpers.GetDriveItemWithAbsoluteUrl(graphClient, "https://mysharepointfilelocation.xlsx");
var tableName = "mytable";
var totalColumns = 134;
var columnIndex = 131;
var startRowIndex = 60;
// create workbook session
var session = await graphClient
.Drives[workbookFileDriveItem.ParentReference.DriveId]
.Items[workbookFileDriveItem.Id]
.Workbook
.CreateSession
.PostAsync(new Microsoft.Graph.Drives.Item.Items.Item.Workbook.CreateSession.CreateSessionPostRequestBody { PersistChanges = true });
var cellValues = new string[] { "MyCellValueA", "MyCellValueB" };
var rows = new string[][] {
cellValues
};
// workaround due to broken SDK
List<UntypedArray> jsonRows = CreateRowValues(totalColumns, columnIndex, rows);
// update row with session
var excelUpdateRowResponse =
graphClient
.Drives[workbookFileDriveItem.ParentReference.DriveId]
.Items[workbookFileDriveItem.Id]
.Workbook
.Tables[tableName]
.Rows["$/ItemAt(index=" + startRowIndex + ")"]
.PatchAsync(new UpdateWorkbookTableRowBody
{
Rows = jsonRows
}, config =>
{
config.Headers.Add("workbook-session-id", session.Id);
});
// close session
await graphClient
.Drives[workbookFileDriveItem.ParentReference.DriveId]
.Items[workbookFileDriveItem.Id]
.Workbook
.CloseSession.PostAsync(c =>
{
c.Headers.Add("workbook-session-id", session.Id);
});
SDK Version
No response
Latest version known to work for scenario above?
No response
Known Workarounds
No to use workbook sessions, which decreases performance
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the C# reproduction and trace the CreateSession, table row PatchAsync, and CloseSession calls, including the workbook-session-id headers and responses. Verify whether the row update is associated with the created session and whether PersistChanges takes effect on close. Done means the workbook table row changes persist when the session-based sequence runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100