删除空的共享驱动器失败

时间:2019-07-03 12:31:41

标签: google-drive-api

尝试删除[1]个共享驱动器。请求返回403禁止 和以下正文:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "cannotDeleteResourceWithChildren",
    "message": "This resource cannot be deleted because it has children."
   }
  ],
  "code": 403,
  "message": "This resource cannot be deleted because it has children."
 }
}

但是驱动器为空。先前的上一个列表请求立即返回了一个空列表。

几秒钟后再次发出相同的删除请求。

编辑:忘记提及在列表请求之前已删除文件(发送到回收站)。

复制步骤如下:

  • 将共享驱动器下的文件发送到垃圾箱;
  • 列表请求。它返回一个空列表;
  • 删除共享驱动器请求

[1] https://developers.google.com/drive/api/v3/reference/drives/delete

[2] https://developers.google.com/drive/api/v3/reference/files/list

编辑:我可以使用cURL重现此问题。 cURL条目是使用Chrome中的cURL复制为创建的。参见下面的bash脚本及其输出。这是一个包含10个文件的共享驱动器。

DRIVEID=0ANMOBifriUr9Uk9PVA

curl "https://content.googleapis.com/drive/v3/files?corpora=drive&driveId=$DRIVEID&includeItemsFromAllDrives=true&q=trashed%3Dfalse&supportsAllDrives=true&fields=files(id%2Cname)" -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken0' -H 'x-requested-with: XMLHttpRequest' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'sec-fetch-site: same-origin' -H 'x-referer: https://explorer.apis.google.com' --compressed

curl 'https://content.googleapis.com/drive/v3/files/1fkLANZMuX7Tl_6rTQgqFV6x2St48UcVo?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed
curl 'https://content.googleapis.com/drive/v3/files/1dVyvc8x9hqRSG81gbzH7QlXdy9pVPOpF?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed
curl 'https://content.googleapis.com/drive/v3/files/1XNte7tA6g95YOdM4Kfrr-YWs3-c6WtOZ?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed
curl 'https://content.googleapis.com/drive/v3/files/1pQ52Qya4qv9TzvV4MxnXcXZBzlbsc3Ky?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed
curl 'https://content.googleapis.com/drive/v3/files/1ymmxdvHlqZTggK2H5WxAYLYMTwwmh-26?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed
curl 'https://content.googleapis.com/drive/v3/files/1fhwOPeobj_1MRo_eaY-c_MQ2B44LVc3Z?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed
curl 'https://content.googleapis.com/drive/v3/files/1st_wpikySnsAdikUDePGqbo4bDQTEynl?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed
curl 'https://content.googleapis.com/drive/v3/files/1xKpaojPrgqcwWgwCbWse2KGgVwjC7SaW?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed
curl 'https://content.googleapis.com/drive/v3/files/1btL_jLjrUg3oO3y2275lcq2T5VxmESuM?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed
curl 'https://content.googleapis.com/drive/v3/files/1TBypd04jm7s3gVo0fc61hs4Gx7Uo4E0Y?supportsAllDrives=true&alt=json' -X PATCH -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken' -H 'x-requested-with: XMLHttpRequest' -H 'sec-fetch-site: same-origin' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --data-binary '{"trashed":true}' --compressed

curl "https://content.googleapis.com/drive/v3/files?corpora=drive&driveId=$DRIVEID&includeItemsFromAllDrives=true&q=trashed%3Dfalse&supportsAllDrives=true&fields=files(id%2Cname)" -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken2' -H 'x-requested-with: XMLHttpRequest' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'sec-fetch-site: same-origin' -H 'x-referer: https://explorer.apis.google.com' --compressed

curl "https://content.googleapis.com/drive/v3/drives/$DRIVEID" -X DELETE -H 'sec-fetch-mode: cors' -H 'x-goog-encode-response-if-executable: base64' -H 'accept-encoding: gzip, deflate, br' -H 'x-origin: https://explorer.apis.google.com' -H 'accept-language: en-US,en;q=0.9' -H 'authorization: Bearer AuthToken3' -H 'x-requested-with: XMLHttpRequest' -H 'x-clientdetails: appVersion=5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1&platform=Win32&userAgent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F77.0.3829.0%20Safari%2F537.36%20Edg%2F77.0.197.1' -H 'x-javascript-user-agent: apix/3.0.0 google-api-javascript-client/1.1.0' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3829.0 Safari/537.36 Edg/77.0.197.1' -H 'accept: */*' -H 'referer: https://content.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.pt_BR.9VS-OXqJJxY.O%2Fam%3DwQE%2Fd%3D1%2Frs%3DAGLTcCOat2vY5WjTVOTl0GbC_09htXr7UQ%2Fm%3D__features__' -H 'authority: content.googleapis.com' -H 'sec-fetch-site: same-origin' -H 'x-referer: https://explorer.apis.google.com' -H 'origin: https://content.googleapis.com' --compressed

这是输出

{
 "files": [
  {
   "id": "1fkLANZMuX7Tl_6rTQgqFV6x2St48UcVo",
   "name": "file-0010"
  },
  {
   "id": "1dVyvc8x9hqRSG81gbzH7QlXdy9pVPOpF",
   "name": "file-0005"
  },
  {
   "id": "1XNte7tA6g95YOdM4Kfrr-YWs3-c6WtOZ",
   "name": "file-0004"
  },
  {
   "id": "1pQ52Qya4qv9TzvV4MxnXcXZBzlbsc3Ky",
   "name": "file-0002"
  },
  {
   "id": "1ymmxdvHlqZTggK2H5WxAYLYMTwwmh-26",
   "name": "file-0003"
  },
  {
   "id": "1fhwOPeobj_1MRo_eaY-c_MQ2B44LVc3Z",
   "name": "file-0001"
  },
  {
   "id": "1st_wpikySnsAdikUDePGqbo4bDQTEynl",
   "name": "file-0008"
  },
  {
   "id": "1xKpaojPrgqcwWgwCbWse2KGgVwjC7SaW",
   "name": "file-0007"
  },
  {
   "id": "1btL_jLjrUg3oO3y2275lcq2T5VxmESuM",
   "name": "file-0006"
  },
  {
   "id": "1TBypd04jm7s3gVo0fc61hs4Gx7Uo4E0Y",
   "name": "file-0009"
  }
 ]
}
{
 "kind": "drive#file",
 "id": "1fkLANZMuX7Tl_6rTQgqFV6x2St48UcVo",
 "name": "file-0010",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "kind": "drive#file",
 "id": "1dVyvc8x9hqRSG81gbzH7QlXdy9pVPOpF",
 "name": "file-0005",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "kind": "drive#file",
 "id": "1XNte7tA6g95YOdM4Kfrr-YWs3-c6WtOZ",
 "name": "file-0004",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "kind": "drive#file",
 "id": "1pQ52Qya4qv9TzvV4MxnXcXZBzlbsc3Ky",
 "name": "file-0002",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "kind": "drive#file",
 "id": "1ymmxdvHlqZTggK2H5WxAYLYMTwwmh-26",
 "name": "file-0003",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "kind": "drive#file",
 "id": "1fhwOPeobj_1MRo_eaY-c_MQ2B44LVc3Z",
 "name": "file-0001",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "kind": "drive#file",
 "id": "1st_wpikySnsAdikUDePGqbo4bDQTEynl",
 "name": "file-0008",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "kind": "drive#file",
 "id": "1xKpaojPrgqcwWgwCbWse2KGgVwjC7SaW",
 "name": "file-0007",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "kind": "drive#file",
 "id": "1btL_jLjrUg3oO3y2275lcq2T5VxmESuM",
 "name": "file-0006",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "kind": "drive#file",
 "id": "1TBypd04jm7s3gVo0fc61hs4Gx7Uo4E0Y",
 "name": "file-0009",
 "mimeType": "application/octet-stream",
 "teamDriveId": "0ANMOBifriUr9Uk9PVA",
 "driveId": "0ANMOBifriUr9Uk9PVA"
}
{
 "files": []
}
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "cannotDeleteResourceWithChildren",
    "message": "This resource cannot be deleted because it has children."
   }
  ],
  "code": 403,
  "message": "This resource cannot be deleted because it has children."
 }
}

最感兴趣的是最后两个响应:[2]返回一个空列表

{
 "files": []
}

但是[1]给出了错误。

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "cannotDeleteResourceWithChildren",
    "message": "This resource cannot be deleted because it has children."
   }
  ],
  "code": 403,
  "message": "This resource cannot be deleted because it has children."
 }
}

1 个答案:

答案 0 :(得分:0)

这里的问题是,当您回收文件时,该文件仍链接到回收该文件的驱动器,以便您在需要时可以将其恢复。只需将trashed属性更新为True并不会删除文件和父驱动器之间的链接。

您可以在此处执行以下几项操作-您可以删除文件,然后使用Files: update更改链接的父项,并确保使用以下参数:

fileId = 'ID of file'
supportsAllDrives = True
addParents = 'Drive ID of different Drive'
removeParents = 'ID of Shared Drive you want to delete'

文件必须至少具有一个父链接,因此需要先添加新链接,然后再删除共享的云端硬盘链接。

另一种选择是直接删除文件,而不是将其发送到垃圾箱-仅在您确定不必恢复文件的情况下才执行此操作,因为这样做后无法恢复该文件。这是使用Files: delete()方法完成的,同样,您将需要使用以下参数:

fileId = 'ID of file'
supportsAllDrives = True

允许您使用Drives: delete()方法删除驱动器。