问题
I am trying to check the date of the latest modification to a google sheet using pygsheets 1.1.4, google-api-python-client 1.6.7, and Python 3.6.3 on Windows 10.
I can authenticate, view, and edit spreadsheet contents, but when I try to get the last-modified date:
my_client = pygsheets.authorize(service_file=secret_service_acct_file)
my_worksheet = my_client.open_by_key(my_key)
last_updated = my_worksheet.updated
I instead get the following error:
Traceback (most recent call last):
File "<pyshell#77>", line 1, in <module>
my_worksheet.updated
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pygsheets\spreadsheet.py", line 90, in updated
response = self.client._execute_request(self.id, request, False)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\pygsheets\client.py", line 459, in _execute_request
response = request.execute()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\googleapiclient\http.py", line 840, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://www.googleapis.com/drive/v3/files/{API_KEY}?fields=modifiedTime&supportsTeamDrives=false&alt=json returned "File not found: {API_KEY}.">
This, to me, indicates that the file is not found. I would expect other read/write operations to fail if the authorization or the connection had some issue. I have tried opening the spreadsheet with open_by_url()
instead, but received the same results.
I am using google-api-python-client v1.6.7 and pygsheets v1.1.4, freshly installed from GitHub. I have tried running in "administrator" mode and running with no_cache=True
, as per suggestions in other pygsheets questions like this one, to no avail.
I was using gspread 0.6.2 until I realized I would eventually need "Team Drive" support. gspread 3.0.0 claims to offer "Team Drive" support, but also deprecated the .updated
attribute that I need.
How can I get my latest modifiedTime
with pygsheets, or should I be using a different library altogether?
edit: I noticed that pygsheets uses the v3 Sheets API for the attribute I'm trying to call, and another SO answer describes the removal of "file oriented" options between the v3 Sheets API and the v4 Sheets API, but the migration guide from google doesn't seem to have any hints for my use case.
来源:https://stackoverflow.com/questions/50380144/pygsheets-updated-returns-file-not-found