I want to use Google Drive from Postman, and when I tried to hit the API I am geting an error.
URL:
https://www.googleapis.com/drive/v3/files/1Iwvqcx073GhEU9eRD4vPihXoj2AV63LEyLZwu6i0jTQ?alt=media
I am getting:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fileNotDownloadable",
"message": "Only files with binary content can be downloaded. Use Export with Google Docs files.",
"locationType": "parameter",
"location": "alt"
}enter code here
],
"code": 403,
"message": "Only files with binary content can be downloaded. Use Export with Google Docs files."
}
}
you need to add responseType: 'blob' if you are trying to get a pdf file
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data
Check this link for more info on how to handle file content download
Related
I am trying to list all permissions assigned to files/folders under the shared drive for the purpose of retrieving external collaborators.
It seems I have proper access right for All the files and folders since I can list/get them via drive API, but when it comes the the permission, the API claims the file/folders do not exist.
Is this the known behavior, or there is another way of retrieving permissions from files/folders in the shared drive?
request and response
request
GET https://www.googleapis.com/drive/v3/files/[FILE ID]/permissions?useDomainAdminAccess=true&key=[YOUR_API_KEY] HTTP/1.1
response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: [FILE ID].",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
"message": "File not found: [FILE ID]."
}
}
Answer:
You need to make your request with useDomainAdminAccess set to false and supportsAllDrives set to true.
Example Request:
GET https://www.googleapis.com/drive/v3/files/[FILE_ID]/permissions?supportsAllDrives=true&key=[YOUR_API_KEY]
Downloading a file via a GET request sometimes results in this error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "cannotDownloadFile",
"message": "This file cannot be downloaded by the user."
}
],
"code": 403,
"message": "This file cannot be downloaded by the user."
}
}
I'm still identifying what type/s of files results in this error. I've tried looking for the cause in the Drive API v3 documentation, but it seems that it isn't mentioned anywhere.
Anyone know what causes this? Thanks!
From what I've observed so far, this happens for files where the option "Disable options to download, print, and copy for commenters and viewers." is set.
https://support.google.com/docs/answer/2494893?co=GENIE.Platform%3DDesktop&hl=en
I want to limit the capabilities of a file in personal Google Drive. When I use the API explorer Google Drive v3 API with the following request:
POST https://www.googleapis.com/drive/v3/files?key={YOUR_API_KEY}
{
"capabilities": {
"canCopy": false
},
"name": "testfile"
}
I get the following response:
403
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fieldNotWritable",
"message": "The resource body includes fields which are not directly writable."
}
],
"code": 403,
"message": "The resource body includes fields which are not directly writable."
}
}
Which is the same response that I get when trying to update a file with:
PATCH https://www.googleapis.com/drive/v3/files/FileIdHere?key={YOUR_API_KEY}
{
"capabilities": {
"canCopy": false
}
}
It seems that there are no methods to accomplish this or has anyone a workaround?
If you check file resource you will notice that some fields are writeable while others are not.
The message you are seeing is because the field you are trying to set is not writeable this means you can not change it from the API
I would like to use Google Drive API to share a file with anyone that has the link to view the file.
However, i failed with error 403, even if I used admin account
"code": 403,
"message": "The user does not have sufficient permissions for this file."
I tried using the API Explorer but still failed.
Followings are my parameters, please help
fileID:"xxxxxxx"
Request Body
{
"role": "reader",
"type": "anyone"
}
And the response
Response
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientFilePermissions",
"message": "The user does not have sufficient permissions for this file."
}
],
"code": 403,
"message": "The user does not have sufficient permissions for this file."
}
}
Please check and help.
Thanks
I'm not able to get information about a file.
Here it is my situation:
I'm logged in google drive
Through google picker I get the file ID
Then I type the url https://www.googleapis.com/drive/v1/files/[file ID]
But I get the following error:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "Daily Limit Exceeded. Please sign up"
}
}
How can I sort it out?
You can't retrieve the file metadata by typing the url in your browser.
Instead you need to send an authorized request with a valid OAuth 2.0 token.
For more information:
https://developers.google.com/drive/about_auth