Home > other >  I am trying to seperate the numbers to odd and even and then pass to to the url path using variable
I am trying to seperate the numbers to odd and even and then pass to to the url path using variable

Time:04-14

I have a get request from where I am taking all the id values , using json extractor I have extracted and named it id and used match number as -1

Now I want to pass this id variable into a post url paths

And this post requests are set inside a for each controller to run for required no of iterations

I have given for each controller values as Input variable : id Start index : 0 End index : ${id_matchNr} Output var name : outid

Paths arelike

Post Path 1: https://demo.qwe.com/blue${outid}

Post Path 2: https://demo.qwe.com/blue${outid}

I want to pass only even id numbers to path 1 and odd id numbers to path two

So I have used if controller and gave expression as ${outid}%2==0 to first path And ${outid}%2!=0 to other if controller and placed the path 2 request And checked the interpret condition

These two rqsts are in for each controller.

When I run the script I am getting a blank output for the post rqsts.

Can you please help me out

CodePudding user response:

The function or variable you put in the If Controller must evaluate to true, only this way the If Controller will run its children. In your case you're providing just a string.

You need to wrap it into i.e. __jexl3() function like:

${__jexl3(${outid}%2==0,)}

this way it should work as expected.

More information: 6 Tips for JMeter If Controller Usage

  • Related