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?
@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": "" }]
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.
If you are testing out the endpoint you should be using {cardidlong} instead of {cardid}
It looks like you're new here. Sign in or register to get started.