问题描述
Trello 增加了在单张卡片上放置封面"的功能.这可以是纯色或图像.
Trello have added ability to put a 'cover' on individual cards. This can be a solid color or an image.
根据他们的 API,您应该能够通过 PUT 请求更新它.请参阅此处,其中讨论了更新卡片,并包括封面".Card 包含多个数据项(json),例如:
Per their API, you should be able to update this via a PUT request. See here which talks about updating a card, and includes the 'cover'. The Card contains a number of data items (json), such as:
desc":旧描述",
封面":{亮度":光",颜色":空,idAttachment":空,idUploadedBackground":空,尺寸":正常"},
"cover": {"brightness": "light","color": null,"idAttachment": null,"idUploadedBackground": null,"size": "normal"},
我可以通过 PUT 更新卡上的其他详细信息,例如desc",如下所示:
I'm able up update other details on the card, eg the 'desc' via a PUT, eg as follows:
import requests
url = "https://api.trello.com/1/cards/{myCardID}"
query = {'key': "{myAPIkey}", 'token': "{myToken}"}
payload = {'desc': 'new desc',}
response = requests.request("PUT", url, params=query, data=payload)
print(response.text)
这成功地将 desc 更新为new desc",如下所示:
This successfully updates the desc to 'new desc' as follows:
desc":新的描述",
我无法确定更新封面颜色需要传递什么.我想我应该能够在上面的代码中传递它,但它不起作用.
I cant work out what I need to pass to update the Cover color. I think I should be able to pass this in the code above but it doesnt work.
payload = {'cover': {'color': 'purple'} }
我总是为封面对象中的颜色获取空值.
I always get null for the color in the cover object.
封面":{亮度":光",颜色":空,idAttachment":空,idUploadedBackground":空,尺寸":正常"},
我需要在 PUT 请求中作为数据/有效负载传递什么????
注意:有效颜色为粉红色"、黄色"、石灰"、蓝色"、黑色"、橙色"、红色"、紫色"、天空"、绿色"
推荐答案
以下代码对我有用:
headers = {
"Accept": "application/json"
}
url = "https://api.trello.com/1/cards/{card_id}/cover"
params = {"key":key,"token":token,"value":{'idAttachment': None,
'color': 'purple',
'idUploadedBackground': None,
'size': 'full',
'brightness': 'light'}}
response = requests.request("PUT", url, headers=headers, json=params)
替换 url 中正确的卡片 ID,
Replace the right card id within the url,
祝你好运
这篇关于用于更新卡片封面颜色的 Python Trello API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!