Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,639,444
Community Members
 
Community Events
196
Community Groups

get last attachment ID when returning {httpresponse} with Butler?

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?

1 answer

0 votes
milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 29, 2022

@Kalvin Lyle 

{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": ""
  }
]

milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 31, 2022

@Kalvin Lyle 

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.

milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 31, 2022

@Kalvin Lyle 

If you are testing out the endpoint you should be using {cardidlong} instead of {cardid}

milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 31, 2022

@Kalvin Lyle 

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

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}"

Hmm scratch that, it works sometimes...

milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 01, 2022

@Kalvin Lyle 

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.

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.

milynnus
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Apr 01, 2022 • edited

@Kalvin Lyle 

Got it to work

Screen Shot 2022-04-01 at 6.36.42 PM.jpg

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events