0
votes

I have a issue in passing dynamic value in request header of jmeter script. Here is the sequence:

Http Request1: Regular expression extractor for extracting the dynamic value from Response Header -- this is ok , variable C_Xscrftokenid2 stores the dynamic string.

Http request2: Pass this C_Xscrftokenid2 Dynamic value to the request Header (web_add_header..)--> Failing Reason:${C_Xscrftokenid2}-> in the output i dont see the value inside the braces getting replaced with the dynamic value instead i simply see the output as below:

Request Headers:

MaxDataServiceVersion: 2.0

X-Requested-With: XMLHttpRequest

x-csrf-token: ${C_Xscrftokenid2}

May i know the reason? Thank you.

2

2 Answers

0
votes

Make sure in your Regular expression extractor field to check is set to Response Headers as shown below

enter image description here

In your HTTP request 2 Header Manager use ${Variable_Name} to pass extracted variable.

I would suggest you to add a debug sampler and see if it is extracting the variable correctly or not.

If you are getting an empty value in debug sampler result then the problem could be with regular expression you are trying to extract.

In my case i wanted to extract X-Frame-Options from response headers and pass it to next header its working as expected enter image description here enter image description here

Follow this link for more information on extracting variables

0
votes

Check your "HTTP Header Manager" is under the "HTTP sampler" and not at the same level. Hope this help.