Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workbook session not persisting changes #2489

Open
craig-blowfield opened this issue May 14, 2024 · 2 comments
Open

Workbook session not persisting changes #2489

craig-blowfield opened this issue May 14, 2024 · 2 comments
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@craig-blowfield
Copy link

craig-blowfield commented May 14, 2024

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_
@craig-blowfield craig-blowfield added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels May 14, 2024
@craig-blowfield
Copy link
Author

Could I have a response to this raised issue please as it is holding up completing client work

@craig-blowfield
Copy link
Author

Also note that I tried the documented table update row endpoint

https://graph.microsoft.com/v1.0/drives/{drive-id}/items/{drive-item_id}/workbook/tables/{table-name}/rows/{index}

with body

{
"index": 1
...
}

Which fails with

{
    "error": {
        "code": "ApiNotFound",
        "message": "The API you are trying to use could not be found. It may be available in a newer version of Excel. Please refer to the documentation: \"https://docs.microsoft.com/office/dev/add-ins/reference/requirement-sets/excel-api-requirement-sets\".",
        "innerError": {
            "code": "apiNotFound",
            "message": "The API you are trying to use could not be found. It may be available in a newer version of Excel. Please refer to the documentation: \"https://docs.microsoft.com/office/dev/add-ins/reference/requirement-sets/excel-api-requirement-sets\".",
            "date": "2024-05-16T10:43:54",
            "request-id": "e16d020f-d381-40e0-a93b-84d14ae96988",
            "client-request-id": "bdfa2156-beb5-7cd1-261a-2392d83beff0"
        }
    }
}

But using ItemAt as shown in my code works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

1 participant