Setting variable in pre-request script in Runscope does not work
search cancel

Setting variable in pre-request script in Runscope does not work

book

Article ID: 218838

calendar_today

Updated On:

Products

BlazeMeter

Issue/Introduction

In a pre-request script I want to set a variable to use then in my request. Let's say my pre-request script looks like this:

var token = "x";

variables.set("token", token);

And if I want to use the variable {{token}} in the request itself, I am getting error: Request failed to set 'body' — Variable 'token' was not defined

Environment

Release :

Component : BLAZEMETER PERFORMANCE TESTING

Resolution

      We can not use the variable created in pre-request scripts in same request. Because the requests template is already prepared in backend. So, the created variable can be used in further steps.

       Please find more details from below documentation. Let me know if you have any further questions.

https://guide.blazemeter.com/hc/en-us/articles/360001822737