Scope of .exec and variables passed between the scopes

I have this (partly simulation):


.header(“X-Token”, “my_token”)
.exec(session2 => {

.header(“X-Token”, “my_token”)
.body(StringBody("""{“offerId”: “${offerId}”, “membershipId”: “1361300168”, “osName”: “Android”, “osVersion”: “4.4”}""")).asJSON


In the last .exec I am trying to use the variable saved in the first .exec without any luck.
It fails. But when ‘hard-coding’ the variable into the StringBody it works. I have verified that ‘offerId’ is captured using my reggae and print.

Is it possible to pass one variable (offerId) from one .exec to the next?

I am actually using ELFileBody and a request body with the parameter ‘offerId’ but that did not work either, so I am using StringBody to ‘debug’.

Please advice,


My guess is the first “offerId” in request body is evaluated as the value of offerId and not the name as you intend it to.

Try changing the name to something like myOfferId


.body(StringBody("""{"offerId": "${myOfferId}"......

thanx :slight_smile:

What you are doing should work. Beware of typos. Because it uses strings, a mis-typed letter can make it not work, even though it compiles. That’s why I started using constants.

Yes, typo it was…