0
votes

I am trying to carry out a test as like it explained here: JMeter Alter HTTP Headers During Test.

Quote from above :

I'm attempting to test an HTTP service with JMeter. The HTTP service requires authentication through a simple bearer token mechanism. I'm trying to proceed as follows:

  • POST authentication request Store token as a variable
  • Set Authorization HTTP header to stored variable
  • Request protected resource(s)
  • Evaluate performance

When the POST occurs, I am not able to capture the bearer token. Its a header.

I tried the solution provided by Dmitri on that issue Or as Bennet tried with RegEx Extractor and HTTPs Manager.

I think I am doing something silly not to able to extract the token. Any thoughts how to extract the token?

1

1 Answers

0
votes

Most likely your Regular Expression Extractor configuration is not correct, by default it:

  • uses response body as a source therefore you need to switch it to look into response headers (red rectangle)
  • looks up in main sample only, if your header is set after redirect it won't be processed (amber rectangle)

    Example configuration:

    Regular Expression Extractor for Headers

You can double check ${bearer} variable value using Debug Sampler and View Results Tree listener combination.