I'm struggling to properly form an API call to change the cover color for a card. I posted the approach I'm taking in StackOverflow as well here.
I suspect I have a problem of proper formation of the PUT request. I've tried it in my Python code, using Postman, and using a simple cURL command, all with similar results. Here's the basic form that I have tried:
Except when I make a gross syntax error, the API returns a JSON that simply returns the current color of the card's cover (and a lot of other attributes of the card). The color of the cover does not actually change. I asked for pink and I got confirmation of green:
Is there a chance the Trello API is color blind? ;-)
For those looking for it, the capability is documented in the API and discussed here.
Any hints about how to properly form this request?
Paul
Community moderators have prevented the ability to post new answers.
I think it’s because you actually need to PUT the JSON in the body of your request. You are appending it to the query string like it’s a GET but you need to specify the content-type text/JSON and actually send the JSON payload in the body of the request (I think).
OK. You were right. Here is the syntax for those who need it:
curl -H 'Content-Type: application/json' -X PUT -d '{"cover" : {"color":"pink"}}' https://api.trello.com/1/cards/24CHARCARDNUMBER?token=64CHARTOKEN&key=32CHARKEY
If you're doing it in python with the urllib3 library, it owuld be this:
params = {"cover" : {"color":"pink"}}
#got the id, now send the message to color it pink result = http.request( "PUT", "https://api.trello.com/1/cards/" + new_card_id + "?key=" + trello_api_key + "&token=" + trello_token, body=json.dumps(params), headers={'Content-Type': 'application/json'} )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.