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

Excel Update tablerow PatchAsync not available #2699

Closed
martinlammers opened this issue Oct 6, 2024 · 2 comments
Closed

Excel Update tablerow PatchAsync not available #2699

martinlammers opened this issue Oct 6, 2024 · 2 comments
Labels
dependency:metadata Awaiting fix from core dependency project module type:feature New experience request

Comments

@martinlammers
Copy link

martinlammers commented Oct 6, 2024

I am trying to update a row in a table using GraphApi. According to the documentation, the code should look like this:

`using Microsoft.Graph.Models;
using Microsoft.Kiota.Abstractions.Serialization;

var requestBody = new WorkbookTableRow
{
Index = 99,
Values = new UntypedString("values-value"),
};

var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Workbook.Tables["{workbookTable-id}"].Rows["{workbookTableRow-id}"].PatchAsync(requestBody);`

I get the error message “The Api you are trying to use could not be found.”

The http call according to the documentation looks like this and does not work either. I get the same error message in Graph Explorer:

`PATCH https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/tables/{id|name}/rows/{index}
Content-type: application/json

{
"index": 99,
"values": "values-value"
}

If I call the following in Graph Explorer, it works:

https://graph.microsoft.com/v1.0/drives/drive-id/items/driveItem-id/workbook/tables/table-id/rows/**itemAt(index=0)** { "values": "values-value" }

I think PatchAsync is missing. The call should look like this:

`var requestBody = new WorkbookTableRow
{
Values = new UntypedArray(new List
{
new UntypedArray(new List
{
new UntypedString("column1-value"),
new UntypedString("column2-value")
})
})
};

var result = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Workbook.Tables["{workbookTable-id}"].Rows.ItemAtWithIndex(99).PatchAsync(requestBody);`

@martinlammers martinlammers added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:feature New experience request labels Oct 6, 2024
@andrueastman andrueastman removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Oct 8, 2024
@andrueastman
Copy link
Member

Thanks for raising this @martinlammers

This looks to be an issue with the API metadata and API implementation you can however work around this in the meantime by making the request to the undocumented endpoint as below.

            var requestInformation = graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Workbook.Tables["{workbookTable-id}"].Rows.ItemAtWithIndex(99).ToGetRequestInformation();
            requestInformation.HttpMethod = Method.PATCH; // set the method to PATCH
            requestInformation.SetContentFromParsable(graphClient.RequestAdapter,"application/json", requestBody); // set the content of the request to the workbookTableRow object
            var response = await graphClient.RequestAdapter.SendAsync<UntypedNode>(requestInformation, UntypedNode.CreateFromDiscriminatorValue);

@andrueastman andrueastman added the dependency:metadata Awaiting fix from core dependency project module label Oct 8, 2024
@martinlammers
Copy link
Author

Thanks that works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependency:metadata Awaiting fix from core dependency project module type:feature New experience request
Projects
None yet
Development

No branches or pull requests

2 participants