How to get a detailed list of google doc revisions in Drive API
Asked Answered
K

1

14

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?

Kiaochow answered 28/10, 2012 at 8:20 Comment(1)
RelatedClaar
A
1

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/

Antirrhinum answered 8/4, 2016 at 15:23 Comment(2)
This won't show the "more detailed revisions" that you can see from the web interface, it will only show the grouped-together revisions. See this post.Claar
i also experiencing issue with this api as i need to get the revision name, current response is just a metadata and not includes the revision nameBarefaced

© 2022 - 2024 — McMap. All rights reserved.