未知名称"update_sheet_properties"; [英] Unknown name "update_sheet_properties"
本文介绍了未知名称"update_sheet_properties";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用google-client-api-python v4并尝试使用以下代码更新工作表的属性
I am using the google-client-api-python v4 and trying to update the properties of a sheet using the following code
for sheet in result.get('sheets', ''):
sheetId = (sheet.get("properties", {}).get("sheetId", 0))
batch_request = {
"requests": [
{
"UpdateSheetProperties": {
"properties": {
"sheetId": sheetId,
"gridProperties": {
"rowCount": 2000,
"columnCount": 4,
}
}
}
}
],
}
result = service.spreadsheets().batchUpdate(spreadsheetId=spreadsheetId, body=batch_request).execute()
运行脚本时出现以下错误
When I run the script I get the following error
json返回接收到无效的JSON有效负载.未知名称 "requests [0]"处的"update_sheet_properties":找不到字段."
json returned "Invalid JSON payload received. Unknown name "update_sheet_properties" at 'requests[0]': Cannot find field."
我在做什么错了?
What am I doing wrong?
推荐答案
我发现了错误
首先应该是
"updateSheetProperties": {
代替
"UpdateSheetProperties": {
我还需要下面一行
"fields" : "gridProperties(rowCount, columnCount)"
实际代码为
for sheet in result.get('sheets', ''):
sheetId = (sheet.get("properties", {}).get("sheetId", 0))
batch_request = {
"requests": [
{
"updateSheetProperties": {
"properties": {
"sheetId": sheetId,
"gridProperties": {
"rowCount": 2000,
"columnCount": 4,
}
},
"fields" : "gridProperties(rowCount, columnCount)"
}
}
],
}
result = service.spreadsheets().batchUpdate(spreadsheetId=spreadsheetId, body=batch_request).execute()
周杰伦
这篇关于未知名称"update_sheet_properties";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文