Reputation: 339
I'm load testing my API which requires to authenticate everytime before calling the API. I need to read a query param from HTTP header "Location" and use it in further requests in Jmeter. I tried to use "Regular Expression Extractor" with Location: .+=(.*?)\n
but it didn't work. Any ideas how to read a specific variable from response headers?
Location: https://<<SSO_URL>>/authenticate?code=AbCDEfg1&..... --> extract "code"
Upvotes: 0
Views: 657
Reputation: 168157
You need to change your regular expression to something like:
Location:\s* .*=(.*?)&
And make sure to choose Response Headers
from the scope:
See Regular Expressions chapter of the JMeter User Manual for more details
Also it might be much easier to use the Boundary Extractor, in this case you will just need to provide the "left" and "right" boundaries and it will fetch everything in-between:
Moreover it works faster and consumes less resources, see The Boundary Extractor vs. the Regular Expression Extractor in JMeter article for more information
Upvotes: 1
Reputation: 2076
Please try with this, regex for your question is code=([^&]*)
Upvotes: 1