0
votes

I am passing a token that I have received while using the logging API in Http Header Manager as "Authorization : Bearer 'the token that I received'" in Jmeter and then testing another API which needs that token. It's going fine when I am running the request for one thread(user). But as soon as I'm increasing the no. of threads to 2 or 3, I am not able to get a response as it says, "Tokens cannot be shared. Please create a new token". Is there any way where I can login for two users and get different tokens and then pass the respective tokens for those two users separately to perform different tasks. And can this process be automated as I am trying to test for multiple users? Thanks in advance.

My Test Plan Looks like this: Test Plan My Http Header Manager Looks Like this: enter image description here My Regular Expression Extractor Looks Like this: enter image description here

If I receive my token response like this { "token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJwc2VuMSIsImV4cCI6MTUyNjYzMDA4MywiaXAiOiIxMjcuMC4wLjEifQ.k85RfQgOF2EiCzjVcmcRLgroHMCGb8P1a_Voi4mwzDEMQ3i2xUvNR6sHrHMO05k-b1MKsMBaxxuA-xiZe78_Xw" }

What should my regular expression be like? Am I following the procedures properly?

1
Can you share a picture/design of your test plan. If all threads are in sequence then it should not be the problem. Else there is some other restrictions like multi session not allowed.sunny_teo
Could you please check the images and let me know?Pritha Sen
...You can use 1 instead of 0 in regular expression field "Match No." to get the first value find by the regEx. 0 is working fine in your scenario as it is only one value. This is just a suggestion.sunny_teo

1 Answers

0
votes

I tried to mimic your request and it seems like your regular expression extractor is not under the Login request and hence it is causing issue.

Try to put it under login instead at the same level as shown below:-

enter image description here

I hope it solves your problem, but if not, do share the error logs as I can see there are some errors reported in the top right hand "yellow" warning sign.