我正在使用TrelloAPI将图像上传到Trello卡。Trello默认情况下将图像设置为封面图像。API文档说有一个setCover选项,但我无法让它工作
https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-attachments-post
def __upload_image_to_card(self, connection: dict, card: dict, image_path : str, cover=False):
params = (
('key', connection['trello_api_key']),
('token', connection['trello_api_token']),
)
values = {
'file': (image_path, open(image_path, 'rb')),
'setCover' : (cover),
}
# TODO: Move to node_manager
response = requests.post('https://api.trello.com/1/cards/%s/attachments' % card['id'], params=params, files=values).json()
我试过在布尔值和字符串之间切换,试过去掉括号。我甚至在值中添加了一个错误键,以查看是否可以得到不同的响应。没有阻止上载图像,也没有阻止图像成为默认图像
非常感谢您的帮助
setCover
应该在params
中,而不是在files
/values
中。您可能还需要将其设置为str(cover).lower()
,因为它期望的是true/false
,而不是True/False
或者作为一句格言:
相关问题 更多 >
编程相关推荐