首页 > 解决方案 > 通过 Python 下载 Smartsheet 附件

问题描述

我正在使用 simple-smartsheet 库从 Smartsheet 中的工作表中读取数据,并在工作表的每一行下载现有附件。

我已经可以读取每一行的数据,但是我无法下载现有附件。

import config
from simple_smartsheet import Smartsheet

sheet = smartsheet.sheets.get(id=config.SHEET_ID) 
for row in sheet.rows:
    attachments = row.attachments
    print(attachments)
        

执行上述命令时,我得到结果:

[]

简单智能表

我使用 simple-smartsheet 库,因为它是唯一支持 python 3.6+ 版本的库

我的 python 版本 3.7.5

标签: pythonapismartsheet-api

解决方案


看起来该库尚未实现处理附件的逻辑。

作为解决此问题的替代方法,我使用以下代码实现了一个解决方案:

import requests


#token = 'Your smartsheet Token'
#sheetId = 'Your sheet id'

r = requests.get('https://api.smartsheet.com/2.0/sheets/{sheetId}/rows/{rowId}/attachments', headers={'Authorization': f'Bearer {token}'})

response_json = r.json()

print(response_json)

有关处理附件 Smartsheets 的更多详细信息,请参阅获取附件


推荐阅读