You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Allistair C <al...@gmail.com> on 2012/11/20 13:45:07 UTC

Assistance with dynamic headers in for loop

Hello,

I would love some assistance with one issue I am having. 

I have a registration thread group that uses a http sampler to register a user from a CSV data loader. The CSV has predefined user values including an email. 

The response is JSON and is simply the new user ID. I use a regex extractor to create a variables USERS which I use a foreach controller to iterate over exposing USERID as a variable and to perform other http samples.

Now, each of those samples in the foreach need to be authenticated using 2 headers. I have a header manager in the for loop and have confirmed that you can put per-iteration variables into the value, so this seems fine.

The issue is that the values I need are the email address (from the earlier CSV data load) and the user ID returned and crunched into the foreach loop USERID variable.

I could not figure out a way to do this and so one idea I had was to change the USERS regex to a template like this

${email},$1$

This now makes the USERID variable exposed by the foreach loop something like

a@b.com,10

All I need to do now is separate these 2 by the comma so that the header manager can be given 2 new variables.

I am trying to use 2 regex post processors and using the Apply To Variable setting. I set that to USERID on both, and then each regex is

(.+?),
,(.+?)

I set the reference on each to EMAIL and ID respectively so that I can use ${EMAIL} and ${ID} in the header manager.

But no replacement is happening for the header values. 

I am not sure if I am using Apply To Variable correctly here since the default value of the regex is not even being used.

Yet I know header manager accepts dynamic variable insertion as I tested that with another variable.

Cheers


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org