2017-09-26 84 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

相關問題