Unanswered question

Share variable value extracted from response between virtual user instance ?

In my API, there is two token generate one is static token and other is dynamic token with timestamp. the dynamic token will be valid and unique for each virtual user instance. so what i can do i get this dynamic token from response of API method and pass the same value in request header for each virtual user instance.
could you please guide, how we can do that?

Gautam S.
Gautam S.

Gautam S.

Level
0
33 / 100
points

Answers

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

I'm confused about the title of your question which indicates that you would like to share a value accross different virtual user instances and the description of your issue where you say "the dynamic token will be valid and unique for each virtual user instance".

So do you want to share the same value accross virtual users or only extract the token from one virtual user instance and use it within that same virtual user instance on the request header?

Gautam S.
Gautam S.

Gautam S.

Level
0
33 / 100
points

Extract the token from one virtual user instance and use it within that same virtual user instance(s) on the request header.

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

Ok so it should easy to achieve that. You just need to use a variable extractor to extract your value and then replace your value by that variable on all your request headers.

To replace the values you can either use the search and replace on the variable extractor tab or better move your extractor as framework parameter.

I would suggest you to look at the NeoLoad documentation here

Gautam S.
Gautam S.

Gautam S.

Level
0
33 / 100
points

Sorry to say it is not working.
Here is the case: i created a virtual user and run constant load with simulated user = 2.
The dynamic token (response from one API method) must be same for both virtual user instance. So if one user has dynamic token the other user instance must not call the API to modified the variable .

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

So if i understand correctly, the first user will call the API to get the token and the other virtual users should not call the API otherwise they will get a new token? Is it correct?

So do you mean that user1 should provide that token to the other virtual user instances?

Gautam S.
Gautam S.

Gautam S.

Level
0
33 / 100
points

yes the 1st user will call the API to get token and that token will be used by other user until request date and time is greater than token generation date and time (generated by 1st user).

user 1 will provide that token to the other virtual user instances to further API call.

Nouredine A.
Nouredine A.

Nouredine A.

Level
4
5000 / 5000
points
Team

In that case you can use the shared queue feature. The first user will get the token and put the value on a shared queue. Then the other user can get that value from the shared queue.

For more information, please look at the NeoLoad documentation here