exportlink for Google drive api v3 - google-drive-api

I'm switching to the Google drive V3 apis and I'm not able to retrieve the stream to the document.
Goal: I want to push a google drive document to another location and I need to retrieve the stream of the file in order to use it to push it to the target.
I can't find a way to do it using Google Drive API V3 !
In V2, I used:
downloadUrl = file.ExportLinks[(string)ExportTable[file.MimeType]];
And then I could use something like:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(downloadUrl));
I don't find the equivalent in V3.
I tried:
var getfile = _service.Files.Get(file.Id).Execute();
var request = _service.Files.Export(file.Id, getfile.MimeType);
System.IO.Stream stream = request.ExecuteAsStream();
And the content of the stream is:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "fileNotExportable",
"message": "Export only supports Google Docs."
} ],
"code": 403,
"message": "Export only supports Google Docs."
}
}
Of course, we don't want to download it to a local file and then generate a new stream from the file cached locally. We want to remain entirely in memory.
Thanks for your help

You can see that in the Migrate to Drive v3 docs, it says that:
The exportLinks field has been removed from files. To export Google
Documents, use the
files.export
method instead.
Check that page for other changes in v3 as well.

You can also create a link yourself if you are logged in as the right user or the file is public with a link:
https://docs.google.com/feeds/download/documents/export/Export?id={{ID}}&exportFormat=pdf

Related

403 Forbidden error with Google URL shortener API when accessing public data

I'm trying to expand a public short url using the Google URL Shortener API. The Google URL Shortener API is discontinued from March 30th as described in this blog post. Instead I should be using Firebase Dynamic Links but I can't find any docs on expanding URLs with FDL.
I'm only accessing public data so I have been using the shortener URL api with only an API key:
curl https://www.googleapis.com/urlshortener/v1/url\?shortUrl\=https://goo.gl/maps/JtZ2Yq19vJP2\&key\=MY_API_KEY
I always get the following response:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "forbidden",
"message": "Forbidden"
}
],
"code": 403,
"message": "Forbidden"
}
}
When using the API explorer I'm getting the same response so I'm assuming it's because the API is being discontinued so how can I use Firebase Dynamic Links to do the same?
I am also had same issue since last week. I searched for solution but the reason is Google is shutting down its goo.gl URL shortening service.
https://www.engadget.com/2018/03/30/google-shutting-down-goo-gl-url-shortening-service/

Google Drive Service Account change filename usin API Request

I'm trying to perform next API call using PATCH method on a file that is not in a root directory,
API Call for changing the file name (Picture)
The Response (Picture)
The response of above API Call is a File resource with 200 status code, but the file name doesn't changed ;(
I have tried using API v2 and API v3, unfortunately the response is the same. File Name is not changed. For v3 i have used request body {"name": "New Name"}.
Some help please ?
I'm not interested to use any library for perform this call. I'm interested in raw API Call.
Another API Calls for manipulating with files/folders works like expected. Only this call is not working for me.
Sorry for my English,
Thanks in advance.

Enumerate files in gogle team drive where admin is not part of

I would like to know if a Google drive domain admin can enumerate files in team drive where he is not a member? currently this seems not supported through drive rest api, I'm using below API call to enumerate files and the corresponding error response below. Please let me know if there is any alternative api call to achieve this.
https://www.googleapis.com/drive/v2/files?teamDriveId=&corpora=teamDrive&fields=*&includeTeamDriveItems=true&supportsTeamDrives=true
{
"error": {
"errors": [
{
"domain": "global",
"reason": "teamDriveMembershipRequired",
"message": "The attempted action requires Team Drive membership."
}
],
"code": 403,
"message": "The attempted action requires Team Drive membership."
}
}
You must take note of the following Team Drives: Requirements & access levels before making any requests to Drive API.
Users with G Suite Basic cannot create or access Team Drives
unless they are invited by a member of an external organization that
has Team Drives.
Refer to the table below on what action you can do in every team drives if you are a member.
To learn more about Drive API methods, you can refer to the Drive API documentation.

Google Drive Realtime API "get" endpoint not working as expected

We are trying to use the Google Drive API to retrieve the model of a Realtime document (API reference). However, if I call the "get" method to retrieve details of a Realtime File generated through the Google Drive Realtime API Playground app (with a blank "revision" field), the result is always:
{
"appId": "292824132082",
"revision": 1,
"data": null
}
even after a lot of editing on the model. If I try to specify a different revision (say, "2") the result is a 500 error:
{
"error": {
"code": 500,
"message": null
}
}
Are we doing something wrong or is there a problem with this specific API?
Calling "get" using the API Playground gets the realtime document associated with the API playground app, not the realtime document associated with your app.
If you update and get both with the API playground you should see contents.

Google Drive API, page size of the document

I have been working on Google Drive API. Is there a way to get page size of the documents?(PDF, MS Docs)
The google drive api is a file store api. Its basically a directory api. It stores the files in folders and can give you information about the files itself.
"name": string,
"mimeType": string,
"description": string,
It will allow you to upload and download files to this directory. It does not give you more information beyond that.
You cant read the contents of the file or the settings of the file in anyway with this api.