Reputation: 788
I want to create a Jmeter testplan and I need a object that is create with another object reference. I want to create this object 'owner' 100 times and with the response create 100 'devices' in which one of the fields will be an 'owner_ref'.
I want to create the devices with the corresponding ids like
ownerId1-->device1
ownerId2-->device2 and so on.
Im using now:
testPlan:
HttpRequest
Json Path Postprocessor--> extract 'id' to variable 'ownerId'
How I can create an array of ownerIds and iterate through this 100 to create new request with these ids?
I am thinking in use beanShell but should be another easier and cleaner method to do. Thanks to all!
Upvotes: 0
Views: 2040
Reputation: 13980
As JSON Path PostProcessor documentation states, you can use Match Numbers
parameter:
-1 means extract all results, they will be named as variable name_N (where N goes from 1 to Number of results)
So you could configure your JSON Path PostProcessor like this:
Variable Names: ownerId
...
Match Numbers: -1
Which will produce variables: ownerId1,...,ownerIdN
And then you have a few options, most obvious of them is to use ForEach Controller exactly as help describes
ForEach Controller
Input variable prefix: ownerId
Output variable: currentId
So now any sampler under that controller can use ${currentId}
Upvotes: 1