Search code examples
performanceauthenticationjmetertokenaccess-token

JMeter problem at calling out stored token during real time execution


I am currently using JMeter to perform a basic performance test on a web-application.

For the construction of such, I have used the BlazeMeter recorder as an easy and complete way of building my test plan, in which recorded the static token used at that particular moment of the recording.

But, considering that tokens are generated by each login, this requires me to find a way to successfully store the token from each session (done) and then properly call it out to each individual HTTP Request (this is the obstacle).

Below in my screenshot, is how I have my test plan set, and also how am I calling the already stored token towards the 2nd HTTP POST Request that requires the real-time token, otherwise it will deliver a 401 error. Despite such, when attempting to call and apply the stored token, it now returns a 400 error for reasons that are unknown to me...

I believe the solution is by slightly changing the way I am calling the stored token?


Solution

  • You're getting response as JSON so it makes more sense to use JSON Extractor instead of the Regular Expression Extractor, the relevant configuration would be something like:

    enter image description here

    Also there is no need to do any scripting, if you add a HTTP Header Manager as a child of the request which requires authentication and configure it like:

    enter image description here