我想不断更新/重写Google表格 . 但是,我不能只更新它,而不清除旧表,因为有时更新的行数较少,而前一行和旧行都留在工作表中 .
因此,developer page上列出的协议是:
{
"requests": [
{
"updateCells": {
"range": {
"sheetId": sheetId
},
"fields": "userEnteredValue"
}
}
]
}
转换为python看起来像这样,我想:
requests = [{ 'updateCells': { 'range': { 'sheetId': spreadsheet_id }, 'fields': 'userEnteredValue' } }]
body = { 'requests': requests }
spreadsheet_id='[uniqueIDhere]'
result = service.spreadsheets( ).values( ).batchUpdate(spreadsheetId=spreadsheet_id, body=body ).execute( )
哪个返回错误:
googleapiclient.errors.HttpError:https://sheets.googleapis.com/v4/spreadsheets/ [unitIDhere] /values:batUpdate?alt = json返回“收到的JSON有效负载无效 . 未知名称”请求“:找不到字段 . ”>
似乎很奇怪“请求”无效,因为它在协议中列出 . 无论如何,还有其他人让这个工作吗?谢谢 . - 杰森
2 回答
应该:
我花了很长时间才注意到我的代码中的同样错误......
找到了不同的method:
这很好用 . 仍然想知道为什么requests-updateCells协议不起作用 .