I am trying to find a way to retrieve a detailed list of Google doc revisions using Google Drive API. I have tried to implement it in Java, and it does return a list of 10 revisions. However, this list is not detailed enough. If I go to Google Drive, open this file and check the revisions through "File-see revision history", it will return the same list (of 10 revisions) as I got from the Drive API. But there is a button called "Show more detailed revisions" and it will return a detailed list of revisions if I click on it.
Does anyone know how to get this detailed list through Drive API? Or is there any other alternative ways to get this detailed list of revisions?
You should use both get and list methods to get detailed list of revisions for a google drive file; Below sample should work (I haven't test this):
/**
* Print detail information about revisions of the specified file.
*
* @param service Drive API service instance.
* @param fileId ID of the file to print revisions for.
*/
private static void detailedRevisions(Drive service, String fileId) {
try {
RevisionList revisions = service.revisions().list(fileId).execute();
List<Revision> revisionList = revisions.getItems();
for(Revision revision : revisionList) {
revision = service.revisions().get(
fileId, revision.getId()).execute();
System.out.println("Revision ID: " + revision.getId());
System.out.println("Modified Date: " + revision.getModifiedDate());
if (revision.getPinned()) {
System.out.println("This revision is pinned");
}
}
} catch (IOException e) {
System.out.println("An error occured: " + e);
}
}
Check this for a complete list of Revision class methods:
https://developers.google.com/resources/api-libraries/documentation/drive/v2/java/latest/