接收到无效的JSON有效负载。 “ requests [1] .paste_data.data”处的名称未知:找不到字段

时间:2018-12-06 12:32:41

标签: python google-api google-api-python-client pygsheets

更新: 我在google bactch更新页上使用了api Explorer,并且能够成功更新电子表格,但是当我在代码中复制该电子表格时,仍然出现错误。 API资源管理器确实可以使用json格式。

<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()

0 个答案:

没有答案