I am now working on a software that can track changes in google drive and get the name of the last modifier of each change. I am doing this by accessing revisions of each file and extract "lastModifyingUser" from revisions resource using google drive API.
However, I found return revisions resource only contain "kind", "id", "mimetype" and "modifiedTime". When I try to use .get('lastModifyingUser'), I got None. Which is pretty confusing. I also tried to use .list(), it still return same result. I'll attach my code below for u guys to check possible issues.
# Call seleted files revisions
revisions = []
for i in range (len(seleted_files_week) - 1):
try:
# revisions.append(service.revisions().list(fileId = seleted_files_week[i][3]).execute().get('revisions'))
revisions.append(service.revisions().get(fileId = seleted_files_week[i][3],revisionId = 1).execute())
except:
print("error")
Part of return value I got
[{'kind': 'drive#revision', 'id': '1', 'mimeType': 'application/vnd.google-apps.document', 'modifiedTime': '2018-08-16T06:18:41.664Z'}, {'kind': 'drive#revision', 'id': '1', 'mimeType': 'application/vnd.google-apps.document', 'modifiedTime': '2018-09-05T02:11:35.423Z'}]
lastModifyingUser
from the file using service.revisions().list()
.If my understanding is correct, how about this modification?
lastModifyingUser
from the file using service.revisions().list()
, it uses revisions/lastModifyingUser
as fields
.Please modify as follows.
From:revisions.append(service.revisions().list(fileId = seleted_files_week[i][3]).execute().get('revisions'))
To:
revisions.append(service.revisions().list(fileId = seleted_files_week[i][3], fields = "revisions/lastModifyingUser").execute().get('revisions'))
If I misunderstand your question, I'm sorry.