0

You can't I know. From the docs,

Once you get a list of a file's revisions, you can download the content of any revision by calling the revisions.get method with the parameter alt=media. Revisions for Google Docs, Sheets, and Slides can not be downloaded.

But I'd like to download(pdf) different versions of the same Gdoc file based on date. From the Drive web app you can view versions and print them or restore a version to the head. Is there any way to achieve either using the API? Can you restore some version ? Then you could export the file.

I searched the internets, but couldn't find a way around this.

I'm using the java client api, which gives me this when I try to make a media get request.

{
  "code" : 403,
  "errors" : [ {
    "domain" : "global",
    "location" : "alt",
    "locationType" : "parameter",
    "message" : "Only files with binary content can be downloaded. Use Export with Google Docs files.",
    "reason" : "fileNotDownloadable"
  } ],
  "message" : "Only files with binary content can be downloaded. Use Export with Google Docs files."
}

But I can figure it out if you can answer for any other API too.

abhipil
  • 164
  • 2
  • 13

1 Answers1

2

Looks like a v3 specific issue. I suggest using v2 for that particular call. See https://developers.google.com/drive/v2/reference/revisions#resource , where you will see that the revision resource contains an array called exportLinks. Within that you should find an element {"pdf":"https://xxxxxxxx"}. Make an authenticated GET on that URL.

imho, the provided libraries cause as many problems as they solve. This is a case in point where the library masks access to the v2 API, even though the v2 API is fully supported. So in your code, you will need to extract the Access Token from the drive service object, set that as an http Authorization: Bearer 4a343234we43w43w44 header, then make the two GET REST calls to GET the revisions list and then GET the url corresponding to pdf in the exportLinks.

Community
  • 1
  • 1
pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • Right, got it! I chose to use v3 because I thought latest version equals new features. Guess I was wrong. – abhipil Apr 16 '17 at 19:22
  • Hey, I used the export links to get the pdf, but I'm always getting the head revision regardless of which revisionID i pass in. Have you dealt with this? – abhipil Apr 16 '17 at 19:35
  • Posted a new question on this http://stackoverflow.com/questions/43441317/downloading-gdoc-revisions-from-google-drive-api-v2 – abhipil Apr 16 '17 at 19:39