You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I'm trying to get the last attachment on a card in Butler. When I GET the card attachments I can't seem to parse the JSON to get the last attachment.
I'm using this automation:
when an attachment is added to a card by anyone, get url "https://api.trello.com/1/cards/{cardid}/attachments/?key=[KEY]&token=[TOKEN]", and set the card's description to "{httpresponse}"
The JSON result pastes into the description nicely, but anything I do to try to parse it returns an INVALID JSON.
Any ideas?
{httpresponse} is probably a list of dictionaries. So you might need {httpresponse}[-1].url … Try it. If I have time I will investigate further.
the array is within the {...}, but {httpresponse[0]} does not work.
The returned JSON structure looks like this:
[
{
"id": "",
"bytes": ,
"date": "",
"edgeColor": "#",
"idMember": "",
"isUpload": ,
"mimeType": "",
"name": "",
"previews": [
{},
{},
{}
],
"url": "",
"pos": ,
"fileName": ""
}
]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It seems that you can get to an array for an item in a dictitionary but not to a dictitionary inside an array/list aka a list of dictitionaries.
https://help.trello.com/article/1203-issuing-http-requests-with-butler
Having said that you can use http request to an endpoint that will provide you what you need.
Here I have an example for attachments :
https://github.com/xu2xulim/Superhero/blob/master/Superhero%20on%20deta/Micros/Attachments.md
Currently it has only one endpoint.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you are testing out the endpoint you should be using {cardidlong} instead of {cardid}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Updated the endpoint with the following payload (an example) :
{
"card_id": "{triggercardidlong}","alt_card_id": "{newcardidlong}",
"option" : ""
}
where option can
"" - all attachments,
"first" - the first attachment added on the source card or
"last" - the last attachment added on the source card
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
All the magic is happening in Butler. This seems to work now:
when an attachment is added to a card by anyone, get url "https://api.trello.com/1/cards/{cardid}/attachments/?key=[KEY]&token=[TOKEN]", and set the card's description to "{httpresponse[0].name}"
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.
That's good news. Will you be trying to copy the attachment over or just to get the name.
Do you know if the last attachment is a cardlink or boardlink, will the above still work. In my work, I need to filter those out since they are part of the returned array of attachments.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My plan was to set the card cover by getting the last attachment id using {httpresponse} but this seems not possible using Butler. I can get the last attachment by getting {httpresponse.Badges.Attachments} from the card to get the length, but it doesn't seem possible to subtract 1 from that number to get the last attachment.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.