Revisions list and get missing information

2020-05-03 12:50发布

问题:

Using the Google APIs Explorer as well as the official C# library for Google Drive API v3, the response is missing most of the documented fields. I specifically need access to who did the revisions, which should be accessible via $.lastModifyingUser.

I've tried this on my domain admin account as well as a service account, so it shouldn't be a permission issue, at least not that I can see. What am I doing wrong, if anything?

List:

{
 "kind": "drive#revisionList",
 "revisions": [
  {
   "kind": "drive#revision",
   "id": "1",
   "mimeType": "application/vnd.google-apps.spreadsheet",
   "modifiedTime": "2016-11-16T18:29:29.527Z"
  },
  {
   "kind": "drive#revision",
   "id": "14",
   "mimeType": "application/vnd.google-apps.spreadsheet",
   "modifiedTime": "2016-11-16T18:35:49.184Z"
  },
  ...

Single get:

{
 "kind": "drive#revision",
 "id": "134088",
 "mimeType": "application/vnd.google-apps.spreadsheet",
 "modifiedTime": "2017-05-24T11:48:00.788Z"
}

回答1:

You need to add fields="*", or fields="permissions(id,lastModifyingUser)" to your request to instruct Drive to return the full resource. By default, only a minimal set of properties is returned.



回答2:

I was not able to retrieve the "lastModifyingUser" from the revisions API but I was able to retrieve the "lastModifyingUser" from the Files.get fro example:

    File foundFile = service.files().get(id)
            .setSupportsTeamDrives(true)
            .setFields("parents, webViewLink, properties, lastModifyingUser")
            .execute();

    System.out.println("Found file is " + foundFile);
    System.out.println("Parents " + foundFile.getParents());
    System.out.println("Owners " + foundFile.getOwners());
    System.out.println("Props " + foundFile.getProperties());
    System.out.println("Last user " + foundFile.getLastModifyingUser());