0

I have extracted the jwt token from the User login controller through my http service my test plan looks like this:

Result tree Test plan

As seen in the images in login request it takes the header of Breakdown Configuration and it doesn't take authorization token value pass as a JSON object in Bearer ${token} although I have extracted it in JSON extractor and debug sampler shows it. I have also used the once only controller but it doesn't solve the issue.

Please help in the nested Header Manager and how to use it correctly. Even I have used Bean Shell processor under my GETALL Bd-config request and pass the command:

import org.apache.jmeter.protocol.http.control.Header;
sampler.getHeaderManager().add(new Header("Authorization","Bearer " + vars.get("BEARER"))); 

But it doesn't solve the issue. Please guide.

1
  • import org.apache.jmeter.protocol.http.control.Header; sampler.getHeaderManager().add(new Header("Authorization","Bearer " + vars.get("token")));
    – coder_m
    Commented Nov 28, 2019 at 15:44

1 Answer 1

0

If you want to keep this Extract token Post-Processor at the same level as other Samplers - you will need to remove the Debug Sampler and use i.e. Debug Post-Processor instead as given your current Test Plan:

  1. Extract token Post-Processor is being applied to Login sampler and (hopefully) gets the token
  2. Extract token Post-Processor is being applied to Debug Sampler, at this time your ${token} variable gets overwritten with the blank or default value. One more error is that you're defining the variable holding the token as token and referring BEARER which doesn't have any value
  3. Your GetAll Bd-config` sampler uses default or blank value

Check out JMeter Scoping Rules - The Ultimate Guide article for more information regarding JMeter test elements scope and properly placing them to achieve your goals.

Suggested test plan configuration would be something like:

enter image description here

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.