0
votes

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"
2

2 Answers

1
votes

Please try with this, regex for your question is code=([^&]*)

enter image description here

1
votes

You need to change your regular expression to something like:

Location:\s* .*=(.*?)&

enter image description here

And make sure to choose Response Headers from the scope:

enter image description here

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:

enter image description here

Moreover it works faster and consumes less resources, see The Boundary Extractor vs. the Regular Expression Extractor in JMeter article for more information