2017-09-26 82 views
1

我试图从Python SDK API中检索Users.list_org_sheets(include_all = True)表。如何使用Smartsheets API检索文件夹树Python

与我可以看到所有我需要的东西:

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

ss是smartsheet.Smartsheet(标记)。 所以与我可以看到所有的表在我的领域,但是当我尝试与get_sheet_as_excel(ID,路径)下载,我得到的错误:

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

我想,这个错误意味着他没有” t找到文件(错误404),但我不知道为什么,就在我使命令获得所有工作表的清单之后,然后当我选择其中一个时(我不是拥有此令牌的所有者,而是令牌是系统管理员)

感谢您的帮助

回答

1

您所描述的情况是由于权限Smartsheet是如何工作的。使用系统管理员令牌,就可以顺利拿到列表由帐户的成员拥有的所有表的,但系统管理员令牌不会允许您访问内容这些表的,除非是系统管理员用户已被明确授权访问表单。当您尝试检索工作表时,您会收到“找不到”错误,因为系统管理员用户尚未明确被授予访问该工作表的权限。

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

相关问题