Issue
I was trying to upload my file to GoogleDrive with GoogleDrive API V3 by Curl. It worked fine in my own Drive but not when upload to my team's shared drive. (Because some reason, I can only use the curl command.)
Here is my code:
curl -X POST https://www.googleapis.com/upload/drive/v3/files?&uploadType=multipart \
-H "Authorization: Bearer ${access_token}" \
-F "[email protected];type=application/json;charset=UTF-8" \
-F "[email protected]"
And here is my meta file
{
"name": "test.zip",
"parents": ["MY ID TO FOLDER IN SHARED DRIVE"],
"description": "aa",
}
but it's return error like this
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: MY ID TO FOLDER IN SHARED DRIVE.",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
"message": "File not found: MY ID TO FOLDER IN SHARED DRIVE."
}
}
Can any one tell me what going wrong? Thanks a lot!!
Solution
In your situation, how about the following modification?
Modified curl command:
curl -X POST "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&supportsAllDrives=true" \
-H "Authorization: Bearer ${access_token}" \
-F "[email protected];type=application/json;charset=UTF-8" \
-F "[email protected]"
supportsAllDrives=true
is added. I thought that the reason ofFile not found: MY ID TO FOLDER IN SHARED DRIVE
is due to this. And also, the URL is enclosed by"
.
Modified metadata:
{
"name": "test.zip",
"parents": ["MY ID TO FOLDER IN SHARED DRIVE"],
"description": "aa"
}
,
of"description": "aa",
is removed.
Note:
- This modified curl command supposes that your access token can be used for uploading the file. Please be careful this.
- When you have no write permission for the folder of
"MY ID TO FOLDER IN SHARED DRIVE"
, this modified curl command cannot be used. So please be careful about this.
Reference:
Answered By - Tanaike Answer Checked By - Candace Johnson (WPSolving Volunteer)