1
votes

Unable to use the Bean Shell Pre-Processor variable in the HTTP sampler or in another HTTP request.

Thread Group

Random variable - Id

HTTP sampler (XML body - <id> ${var1}</id>)

   BeanShell Pre Processor


     vars.put("RANDOM_NUMBER", "T${Id}E${Id}");

     var var1 = vars.get("RANDOM_NUMBER");

     log.info("var1 value is " + var1);

HTTP Request (https://${var1})

In the logs, can print the value var1 value is T20E33.

However when trying to refer the variable in the same HTTP sampler or in another HTTP request, the value is not replaced.

Referred link

Even tried directly using RANDOM_NUMBER as ${RANDOM_NUMBER} in request, in this case also the value is not replaced. It goes as ${RANDOM_NUMBER}.

1

1 Answers

1
votes

Use vars.get instead of ${} and concatenate values

vars.put("RANDOM_NUMBER", "T" + vars.get("Id") + "E" + vars.get("Id"));