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

How to use a variable inside curly brackets?

Plutin December 29, 2020

Hi.

 

So my idea is the following: whenever I create a new card (on my board about video games), I want to automatically fetch that game cover image and add it as an attachment (to then appear as the cover image of the card).

 

To realize this idea I am using a Game DB API and Butler to fetch that cover image and then add it as an attachment.

 

This is my current Butler workflow:

Butler.png

 

My issue here is with the second POST. I have made several tests and came to the conclusion that the issue is with using a variable inside curly brackets like it is happening in the POST header: { "client-id": "???", "authorization": "Bearer {httpresponse.access_token}" }

 

On my tests, I also tried adding a comment with the following format "{ {httpresponse.access_token} }" and it saved with exactly that text (i.e. did not replace the variable with its value). But if I used "{httpresponse.access_token}" then it worked correctly.

 

My question is then: is there a way to use variables inside curly brackets in Butler commands?

 

Thank you!

6 answers

1 accepted

0 votes
Answer accepted
Plutin January 4, 2021

To whomever finds himself in the same predicament as me, I leave the solution that worked for me that was achieved with the help from the Trello Support team.

 

Basically, it is not possible to use the `httpresponse` variable inside a JSON object (i.e. inside curly brackets) due to the way that the variable is handled (tip: has to do with regex parsing).

 

So the solution is to store the value that will be used inside a JSON object in another place, like a Custom Field or the card description and then use THAT variable inside the JSON object.

And that's it.

 

In my case, after I received the response from the first POST, I stored the {httpresponse.access_token} variable value in the card description and then for the second POST I used the card description variable to fill the header, like so: { "client-id": "???", "authorization": "Bearer {carddescription}" }

This is the flow:

Butler.png

 

Best regards!

0 votes
Plutin January 1, 2021

Hi @Soumyadeep Mandal ,

 

Just to clarify, that is only one rule but with several actions on it.

I did it that way to test the behaviour of the `httpresponse` variable (and consequentially, also with the `cardname` variable). 

 

Anyway, I will try contacting Trello Support by using the link that you provided. 

 

Thank you for all your support with this. I really appreciate it :)

0 votes
Soumyadeep Mandal
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.
January 1, 2021

Hi @Plutin ,

You have written 3 different things in3 different rules in the screenshot!

{httpresponse.access_token}

{{httpresponse.access_token}}

{ {httpresponse.access_token} }

change all three to 

{httpresponse.access_token}

it doesn't work ask Trello support HERE

0 votes
Plutin January 1, 2021

Happy New Year, @Soumyadeep Mandal !

 

As for the issue, I have recreated again the rule and it still has the same behaviour! Unfortunately :(

0 votes
Soumyadeep Mandal
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.
January 1, 2021

Hi @Plutin ,

Wish you a very Happy New Year!

I think you have misspelled or made the wrong rule!

Delete the rules and recreate them! It was not a bug!

0 votes
Soumyadeep Mandal
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.
December 31, 2020

Hi @Plutin ,

Welcome to the community!

Please follow up this documentation https://help.trello.com/article/1157-variables

Plutin January 1, 2021

Hi @Soumyadeep Mandal

 

Thank you for the welcome. Glad to be here :) 

 

Actually, I had already read that documentation. And all the others that are related to Butler (https://help.trello.com/category/1134-butler). 

Unfortunately this specific case is not mentioned. Or atleast I did not find anything mentioning this particular case of using variables inside curly brackets.

 

But I have done some more tests and noticed something.

 

I have created the following Butler rule:

Butler-1.jpg

 

And when I create a new card on the board that is using this rule, it behaves like the following:

Rule-1.jpg

 

As can be seen, the issue does not occur when using the `cardname` variable but only with the `httpresponse` variable. Which makes me ponder that the issue may be with the `httpresponse` variable and not with all variables (as I was initially thinking). It may be a bug with that particular variable.

 

Can someone confirm that this is really a bug?

But if not, how can I make `httpresponse` work as `cardname` does?

Like Soumyadeep Mandal likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events