【问题标题】:How To Retrieve Folder Tree With Smartsheets API Python如何使用 Smartsheets API Python 检索文件夹树
【发布时间】:2017-09-26 15:24:56
【问题描述】:

我正在尝试使用 Python SDK API 中的 Users.list_org_sheets(include_all=True) 检索工作表。

有了它,我可以看到我需要的所有东西:

lstorg = ss.Users.list_org_sheets(include_all=True)
for entry in lstorg.data:
    print(entry.id)
    print(entry.name)

ss 是 smartsheet.Smartsheet(token)。 因此,我可以看到我域中的所有工作表,但是当我尝试使用 get_sheet_as_excel(id, path) 下载它们时,我得到了那个错误:

print(ss.Sheets.get_sheet('6157394402142084'))
Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    print(ss.Sheets.get_sheet('6157394402142084')
  File "E:\Python\lib\site-packages\smartsheet\sheets.py", line 525, in get_sheet
    response = self._base.request(prepped_request, expected, _op)
  File "E:\Python\lib\site-packages\smartsheet\smartsheet.py", line 218, in request
    raise the_ex(native, str(native.result.code) + ': ' + native.result.message)
smartsheet.exceptions.ApiError: {"requestResponse": null, "result": {"code": 1006, "message": "Not Found", "name": "ApiError", "recommendation": "Do not retry without fixing the problem. ", "refId": null, "shouldRetry": false, "statusCode": 404}}

我猜这个错误意味着他没有找到文件(错误 404)但我不知道为什么,就在我发出命令以获取所有工作表的列表然后当我选择其中一个时(我不是这个令牌的所有者,但令牌是 SysAdmin)

感谢您的帮助

【问题讨论】:

    标签: python api sdk smartsheet-api


    【解决方案1】:

    您所描述的情况是由于权限在 Smartsheet 中的工作方式。使用 SysAdmin 令牌,您可以成功获取帐户成员拥有的所有 Sheets 的 list,但 SysAdmin 令牌将不允许您访问 这些工作表的内容,除非该 SysAdmin 用户已被明确授予访问工作表的权限。当您尝试检索工作表时,您会收到“未找到”错误,因为尚未明确授予 SysAdmin 用户访问 Smartsheet 中该工作表的权限。

    要实际检索“列出组织工作表”响应中列出的工作表,您需要将 Assume-User 标头添加到“获取工作表”API 请求以模拟工作表所有者.您可以在此处找到有关 Assume-User 标头的文档:https://smartsheet-platform.github.io/api-docs/#http-headers

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 2016-06-21
      • 1970-01-01
      • 2011-12-10
      相关资源
      最近更新 更多