【发布时间】:2017-07-18 02:56:21
【问题描述】:
我正在尝试使用duplicateSheet 请求使用batchUpdate() 方法复制工作表:
body['requests'] = [
{
"duplicateSheet": {
"newSheetName": date_today(),
"sourceSheetId": int(sheet_number)
}
}
]
sheet = service.spreadsheets()
request = sheet.batchUpdate(spreadsheetId=spreadsheetId,
body=requestBody)
response = request.execute()
但我收到此错误消息:
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/xxxxxxxxxx_xxxxxxxx-xxxxxxx:batchUpdate?alt=json returned "Invalid requests[0].duplicateSheet: No sheet with id: 3">
但是工作表确实有这个工作表。使用此 JS 代码确认工作表的 ID:
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getIndex();
【问题讨论】:
标签: python google-sheets google-api-python-client