I Have API's to retrieve the token and get Positions nested under Token Generator and API Group threads.

I need to retrieve token only once and set the token to the property and access it across multiple threads.

Reponse from the post request:


enter image description here

JSON Extractor in Token Generator thread

enter image description here

BeanShell PostProcessor in Token Generator thread

props.put("token", jwt_token); 

HTTP Header Manager in API Group thread

Authorization : Bearer ${__P(token)}

but my request headers in second API:

Authorization: Bearer 1

What am i missing here?

  • Are you running both the thread in parallelly or one after another? Apr 10, 2020 at 16:10
  • 1
    @Amol Sequentially Apr 11, 2020 at 14:57
  • Karthik Suresh : Please see my answer. Apr 11, 2020 at 15:17

2 Answers 2


You need to update your code in Beanshell Post Processor.

props.put("token", jwt_token); 

You are trying to set a variable value in a property, but from the code, you have provided you are using jwt_token which is not the value extracted. You should update your code as below -

props.put("token", vars.get("jwt_token")); 
  1. Don't use Beanshell, starting from JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting
  2. You can avoid this JSON Extractor bit and perform the extraction of the JWT token and storing it into a JMeter property in a single line of code to wit:

    props.put('token', new groovy.json.JsonSlurper().parse(prev.getResponseData()).token)

More information:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.