python - Invalid JSON payload received. Unknown name at 'requests[1].paste_data.data': Cannot find field
问题描述
UPDATE: I used the api explorer on the google bactch update page and was able to successfully update the spreadsheet but when I replicate this in my code I am still getting an error. The API explorer did work with the json format.
<HttpError 400 when requesting
Invalid JSON payload received. Unknown name "value_input_option" at 'requests[0]': Cannot find field.
Invalid JSON payload received. Unknown name "data" at 'requests[0]': Cannot find field.">
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
creds =
ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
service = discovery.build('sheets', 'v4', credentials=creds)
client = gspread.authorize(creds)
# find workbook by name and open the first sheet
# make sure you use the right name here
sheet = client.open("forklift").sheet1
# extract and print all of the values
# list_of_hashes = sheet.get_all_records()
spreadsheet_id = '112345'
batch_update_spreadsheet_request_body = {
"requests": [
{
"valueInputOption": "RAW",
"data": [
{
"majorDimension": "ROWS",
"range": "43:48",
"values": [
["www.colossalpoint.com","colossal point llc"]
]
}
]
}
],
"includeSpreadsheetInResponse": True,
"responseIncludeGridData": True
}
request = service.spreadsheets().batchUpdate(spreadsheetId=spreadsheet_id,
body=batch_update_spreadsheet_request_body)
response = request.execute()
解决方案
推荐阅读
- python - 如何从python遍历excel中的单元格
- django - 是否可以将不需要数据库的应用程序添加到 django
- flutter - 如何防止生产颤振应用程序在模拟器中运行?
- javascript - 如何在不添加历史记录的情况下推送到 vue-router?
- javascript - 如何导出函数和数组
- reactjs - 如何在“React.js”中的 ReactTable 行上显示手悬停
- azure - Azure webapp 运行“docker run”两次但无法部署
- java - Java中是否有一个类可以保留重复但不保留数据顺序?
- r - R 循环回归
- python - 如何从 sympy 随机变量中获取分布及其参数