I am writing some Python automation script with Excel Graph API that needs to loop over the rows of a shared excel file and if a row meets criteria, write some value to one of its cells.
After using openpyxl library, using Graph API is very difficult for me to grasp.
I am able to read worksheet usedRange values and even change value at a given cell address, but I have no clue how to loop over the rows.
I tried to get a row range object from usedRange as follows, but it just returns an error. This is my endpoint in Graph Explorer.
https://graph.microsoft.com/v1.0/drives/{drive_id}/items/{item_id}/workbook/worksheets('<worksheet_name>')/usedRange/row
This is my request body for POST request:
{ "row": 4 }
And this is a 400 Bad Request error I am getting:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'row'.",
"innerError": {
"date": "2024-09-10T08:21:14",
"request-id": "29b3dfd7-08b5-446d-b035-1dffa220d15a",
"client-request-id": "4b79cd03-244e-0613-1897-ea442a0171bc"
}
}
}
I would appreciate any ideas on how to loop over the rows using Graph API.