【问题标题】:Google Drive File/sheet API : file not found when I try to copyGoogle Drive File/sheet API:当我尝试复制时找不到文件
【发布时间】:2020-10-19 15:01:57
【问题描述】:

这是我调用的 API 的 URL,用于从 Google Drive File API 复制文件:

https://www.googleapis.com/drive/v2/files/1GWBfT2gApqaeZ2JRjmNID0BlEs_okMg9/copy?convert=true&supportsAllDrives=true&supportsTeamDrives=true&access_token=[my令牌]

它返回“未找到”。

如果我直接从 Google API 参考中尝试,它可以工作,文件被复制: https://developers.google.com/drive/api/v2/reference/files/copy

如果我尝试使用 v.3,并且删除了“convert=true”参数,仍然得到“未找到”。

如果我尝试使用相同文件 ID 的相同 API,但不使用“复制”方法(并且没有“转换参数”),它可以工作,我得到了 V3 和 V2 中的文件: https://www.googleapis.com/drive/v3/files/1GWBfT2gApqaeZ2JRjmNID0BlEs_okMg9/?supportsAllDrives=true&supportsTeamDrives=true&access_token=[my令牌]

这是我设置的范围(在 PHP Google API 客户端中):

  • Google_Service_Drive::DRIVE_FILE
  • Google_Service_Drive::DRIVE
  • Google_Service_Drive::DRIVE_APPDATA
  • Google_Service_Sheets::SPREADSHEETS Google_Service_Sheets::DRIVE
  • Google_Service_Sheets::DRIVE_FILE

感谢您的帮助

【问题讨论】:

    标签: php api file copy


    【解决方案1】:

    我终于找到了错误...

    我必须将自定义请求“POST”设置到 cUrl 的标头中: PHP: curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多