0
votes

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.

1

1 Answers

2
votes

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.