且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Python使用Google API将电子表格复制到另一张电子表格中

更新时间:2021-09-08 09:53:47

接下来的修改如何?

我认为该错误意味着"destinationSpreadsheetId": "1d8CeUxukBIOUpADE6eBlaksS2ptBjI0vIRpVm8ufEbs"的结构错误.当它看到电子表格文档的右侧时. sheets.copyTo ,请求正文为{"destinationSpreadsheetId": ""}.因此,请尝试以下修改.

I think that the error means that the structure of "destinationSpreadsheetId": "1d8CeUxukBIOUpADE6eBlaksS2ptBjI0vIRpVm8ufEbs" is wrong. When it sees the right side of the document of spreadsheets.sheets.copyTo, the request body is {"destinationSpreadsheetId": ""}. So please try a following modification.

copy_sheet_to_another_spreadsheet_request_body = {
    {
  "destinationSpreadsheetId": "1d8CeUxukBIOUpADE6eBlaksS2ptBjI0vIRpVm8ufEbs"
}
}

收件人:

copy_sheet_to_another_spreadsheet_request_body = {
  "destinationSpreadsheetId": "1d8CeUxukBIOUpADE6eBlaksS2ptBjI0vIRpVm8ufEbs"
}

如果我误解了你的问题,对不起.

If I misunderstand your question, I'm sorry.

对于下一个错误,我确认了以下模式.

For the next error, I confirmed following patterns.

  1. 使用此脚本的用户是您要复制的电子表格的所有者时,该脚本当然可以正常工作.
  2. 如果使用此脚本的用户是您要复制的电子表格的所有者,
    • 如果未共享电子表格,则会出现错误"The caller does not have permission".此错误可能与您的情况相同.
    • 如果电子表格以On - Anyone with the link共享,则脚本可以正常工作.
  1. When the user who uses this script is the owner of the spreadsheet that you want to copy, of course, the script works fine.
  2. When the user who uses this script is NOT the owner of the spreadsheet that you want to copy,
    • If the spreadsheet is not shared, the error of "The caller does not have permission" occurred. This error may be the same to your situation.
    • If the spreadsheet is shared as On - Anyone with the link, the script works fine.

从以上结果中,您可以确认要再次复制的电子表格的权限吗?

From above results, can you confirm the permission of the spreadsheet you want to copy again?