AttributeError: 'list' object has no attribute 'serialize' when using WorkbookTableRow

Dennis Tran 0 Reputation points
2024-07-11T11:18:23.8266667+00:00

I am trying to use the MS Graph API to add a row to an Excel file on Sharepoint, but for some reason my request body gets the error AttributeError: 'list' object has no attribute 'serialize'.

The way I defined it is the same as in the documentation on learn.microsoft.com about the Graph API.

My code is:

tableid=await self.user_client.drives.by_drive_id(parent_drive_id).items.by_drive_item_id(src_item_id).workbook.tables.get()
request_body = WorkbookTableRow(
            index = 5,
            values = [
                [
                    1,
                    2
                    
                ],
                [
                    4,
                    5
                    
                ],
            ],
        )
       
    
workbooktableid=tableid.value[0].id
        
result = await self.user_client.drives.by_drive_id(parent_drive_id).items.by_drive_item_id(src_item_id).workbook.tables.by_workbook_table_id(workbooktableid).rows.add.post(request_body)
        

I have tried changing the values part to a dictionary, dataframe and json but none of those work. And if I change it it gives me for instance 'dict object has no attribute 'serialize''. Does anyone have an idea how to correctly define the request body?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,321 questions
0 comments No comments
{count} votes