I have recorded script using BlazeMeter plugin and I want to the use access token which I receive in successful login request, in another request. My Test plan looks like as below
Thread Group : [A]
|- HTTP Sampler - Login Page
|-Regular Expression Extractor [getToken]
|-HTTP Sampler - Other Page
|-Beanshell PreProcessor[Set Header in Authorization]
Regular Expression Extractor parameters and values like below :
Variable Name : token Regular Expression : {“access_token”:”(.+?)" Template : $1$ Match No. : 0
Beanshell PreProcessor script like below
import org.apache.jmeter.protocol.http.control.Header; log.info("Start"); sampler.getHeaderManager().add(new Header("Authorization","Bearer"+vars.get("token"))); log.info(vars.get("token"));