How to use a variable inside curly brackets?
Asked by Plutin:

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](/t5/image/serverpage/image-id/123665i17EB07E269A361EB/image-size/large?v=v2&px=999 "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!


Answers:
author: Plutin
body: 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](https://community.atlassian.com/t5/image/serverpage/image-id/124091iCEF33E087E3A2EAA/image-size/large?v=v2&px=999 "Butler.png")

Best regards!


author: Plutin
body: Hi [@Soumyadeep Mandal](/t5/user/viewprofilepage/user-id/3861721) ,

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 :)


author: Soumyadeep Mandal
body: Hi [@Plutin](/t5/user/viewprofilepage/user-id/4206457) ,

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](http://trello.com/contact)


author: Plutin
body: Happy New Year, [@Soumyadeep Mandal](/t5/user/viewprofilepage/user-id/3861721) !

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


author: Soumyadeep Mandal
body: Hi [@Plutin](/t5/user/viewprofilepage/user-id/4206457) ,

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!


author: Soumyadeep Mandal
body: Hi [@Plutin](/t5/user/viewprofilepage/user-id/4206457) ,

Welcome to the community!

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

comments: author: Plutin
body: Hi [@Soumyadeep Mandal](/t5/user/viewprofilepage/user-id/3861721)

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).](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](https://community.atlassian.com/t5/image/serverpage/image-id/123899iD744A5611217D7A6/image-size/large?v=v2&px=999 "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](https://community.atlassian.com/t5/image/serverpage/image-id/123900i151A7A88E77DBAD0/image-size/large?v=v2&px=999 "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?


Tags: butler