Google Drive API copy() - 404 error

 ̄綄美尐妖づ 提交于 2019-12-11 13:49:07

问题


I'm using Google Drive API in PHP to manage any files (insert, delete, copy..).
Now I need to create a copy of a file in drive folder (insert work fine).
My code is the same of Google reference. I'm find the file ID with search parameters and then call the function:

$parameters = array();
$parameters['q'] = "title = '".$title."' and mimeType = 'application/vnd.google-apps.spreadsheet'";
$files = $service->files->listFiles($parameters);
if (count($files['items'])>0){
    $fileId = $files['items'][0]['id']; // unique file name
    $copiedFile = new Google_Service_Drive_DriveFile();
    $copiedFile->setTitle("copied_file");
    $service->files->copy($fileId, $copiedFile);
}

but when I call copy() I got this error:

 Error calling POST https://www.googleapis.com/drive/v2/files/1adQjO5ABcbTai3GAEU3RBRHGi8u0_7DlaZfgWywxvqk/copy: (404) File not found: 16bRhq0E_OqYQlTys1oFu1vVeAjWl1P_non2-Z3lLdb8

This is the right id of the file to copy:

1adQjO5ABcbTai3GAEU3RBRHGi8u0_7DlaZfgWywxvqk

but what's this id:

16bRhq0E_OqYQlTys1oFu1vVeAjWl1P_non2

How can i solve it ?


回答1:


Now It works. I logout from my application (and delete from google account permission): when I logged in google OAuth request new permission and It work fine.



来源:https://stackoverflow.com/questions/32662407/google-drive-api-copy-404-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!