Pygsheets。更新返回"文件未找到"

时间:2018-05-16 21:28:05

标签: python google-sheets-api pygsheets

我正在尝试使用Windows 10上的pygsheets 1.1.4google-api-python-client 1.6.7 Python 3.6.3 检查谷歌工作表的最新修改日期。

我可以验证,查看和编辑电子表格内容,但是当我尝试获取最后修改日期时:

my_client = pygsheets.authorize(service_file=secret_service_acct_file)
my_worksheet = my_client.open_by_key(my_key)
last_updated = my_worksheet.updated

我反而得到以下错误:

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}.">

对我来说,这表示找不到该文件。如果授权或连接有问题,我希望其他读/写操作失败。我尝试使用open_by_url()打开电子表格,但收到了相同的结果。

我正在使用从GitHub新安装的 google-api-python-client v1.6.7 pygsheets v1.1.4 。我试过跑进去&#34;管理员&#34;根据{{​​3}}等其他问题中的建议,模式并按no_cache=True运行,无效。

我正在使用 gspread 0.6.2 ,直到我意识到我最终需要&#34; Team Drive&#34;支持。 gspread 3.0.0 声称提供&#34; Team Drive&#34;支持,但也弃用了我需要的.updated属性。

如何使用pygsheets获取最新的modifiedTime,或者我是否应该使用不同的库?

编辑:我注意到pygsheets使用v3 Sheets API作为我试图调用的属性,而this one描述了&#34;面向文件的删除&#34; v3表格API和v4表格API之间的选项,但another SO answer似乎没有任何关于我的用例的提示。

0 个答案:

没有答案