0
votes

Am extracting bearer token in jmeter.

  1. In request 221, I have passed user defined variable first

  2. In request 222, I have extracted the token using regex

  3. In request 223, There is no authorization header value in HTTP Header Manager. I have manually added values in HTTP header manager. Name = Authorization & Value= Bearer ${BEARER}

  4. Now there are multiple requests (e.g. 226, 227, 228, 229, 230, ...) and there is no authorization header in it. I need to pass values in HTTP header manager manually.

Is there any way to pass this values in one request and it will auto detect in all subsequent HTTP header manager? It has been time consuming while adding manually in each request.

2

2 Answers

0
votes

Put a header manager above all the requests that needs a particular value in their headers. Now, the request will take value from this header manager and combine it with values of the header manager present under them. Check the below image:-

enter image description here

Hope this help.

0
votes

You can use Search and replace feature in JMeter, No need to go through each and every header search for the value and replace it with ${BEARER}.

Alternatively you can define a general header manager with just Authorization property and place it before 223 request and delete authorization in every header..This approach is tidy as you have to go through each header and delete.

I would suggest using the first approach..

For more informaYou can refer to the header manager

You can refer to this sample as well