Search code examples
gogoogle-drive-apigoogle-drive-shared-drive

How to get all Modifying Users of a specific Revision


Follow up on Google Drive Rest API : How to get all Modifying Users of a specific Revision

It has been approximately 3 years, so I am not sure what the status is, but I thought I would ask again on the status.

I see that Google Drive API @ https://developers.google.com/drive/api/v3/reference/revisions/get

should actually do exactly what has been asked here, but when I make a call to the API it returns null for LastModifyingUser

I am not sure if this is a work in progress API or I am doing something wrong, so any help would be appreciated. Just to provide some reference, I am posting some basic code that is an addition to what can be found here... https://developers.google.com/drive/api/v3/quickstart/go

revision, err := srv.Revisions.Get(fileId, revisionId).Do() //fieldId and revisionId are fatched using proper calls

if err != nil {
    log.Fatalf("Unable to retrieve revision: %v", err)
}
fmt.Println("Revision:")
fmt.Printf("%+v\n", revision.LastModifyingUser)

Solution

    • You want to retrieve the value of lastModifyingUser from Revisions.Get() using Drive API v3.

    If my understanding is correct, how about adding the fields? At the default, the fields are id,mimeType,modifiedTime. So when you want to retrieve only values of lastModifyingUser, please modify as follows.

    From:

    revision, err := srv.Revisions.Get(fileId, revisionId).Do()
    

    To:

    revision, err := srv.Revisions.Get(fileID, revisionID).Fields("lastModifyingUser").Do()
    

    Note:

    • In this modified script, it is supposes that when you run your current script, no error occurs.
    • If you want to add lastModifyingUser to the default values of id,mimeType,modifiedTime, please set the fields to id,mimeType,modifiedTime,lastModifyingUser.

    Reference:

    If I misunderstand your question, I'm sorry.