I'm trying to have my board update based on some results and having a hard time finding the best way to update both a card's position and the color. The idea is to have a card update based on a result, red and to the top to catch my attention; but if everything is working correctly, then green and to the bottom.
So far I have:
def updateCard():
url = f"https://api.trello.com/1/cards/{CARD_ID}/cover"
headers = {
"Accept": "application/json"
}
query = {
'key': API_KEY,
'token': OAUTH_TOKEN,
'name': 'New Title',
'desc': 'New Description',
'pos': 'bottom',
'value': {'color': 'green'}
}
response = requests.request(
"PUT",
url,
headers=headers,
json=query
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
The pseudo code is from: https://developer.atlassian.com/cloud/trello/rest/api-group-cards/#api-cards-id-put and added my own variables.
I noticed that for changing the color, I need to pass the json variable in the response, and have the URL end with '/cover'. However, this does not work when trying to update the position. If I take the /cover
out of the URL, then the position gets updated. Is there a way to have both update at the same time.
Thanks in advance!
The workaround to this issue so far (and if anyone has a better syntax, feel free to add a comment):
url = f"https://api.trello.com/1/cards/{CARD_ID}"
url_cover = f"https://api.trello.com/1/cards/{CARD_ID}/cover"
headers = {
"Accept": "application/json"
}
query = {
'key': API_KEY,
'token': OAUTH_TOKEN,
'name': 'New Title 3',
'desc': 'New Description',
'pos': 'top'
}
json = {
'key': API_KEY,
'token': OAUTH_TOKEN,
'value': {
'brightness': 'dark',
'color': card_color,
'size': 'full'}}
response = requests.request(
"PUT",
url,
headers=headers,
params=query
)
response = requests.request(
"PUT",
url_cover,
headers=headers,
json=json
)