I use JSON Extractor to get value from respond body. Then I want to get this value for Authorization to add to header to use for next http request . How can I get this value in Beanshell? enter image description here
1 Answers
0
votes
In general there is vars
shorthand for JMeterVariables class instance which provides read/write access to JMeter Variables so change your $.api_token
to vars.get("api_token")
and that would be it.
However there are some problems with your script:
Since JMeter 3.1 you're supposed to be using JSR223 Test Elements and Groovy language for scripting as Groovy provides much better performance comparing to Beanshell (and has better Java support and extra set of features on top of Java SDK)
You don't need scripting at all, you can create the header using JMeter's HTTP Header Manager