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 · 4 comments
Open

Workbook session not persisting changes #2489

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

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

@andrueastman andrueastman added Bug: documentation and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Jul 31, 2024
@andrueastman
Copy link
Member

Any chance this is still an issue @craig-blowfield? As this looks to be API related, the place for API questions would be at https://aka.ms/askGraph

@andrueastman andrueastman added the status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close label Aug 7, 2024
@craig-blowfield
Copy link
Author

craig-blowfield commented Aug 9, 2024

Yes @andrueastman I have updated to the latest version and yes it is still an issue.

I have followed the SDK documentation for working with excel sessions and the SDK is allowing me to call the API in this manner, so its an SDK issue, not an API issue.

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants