I am working on a JMeter test plan where I am extracting various values from a JSON response. The plan requires me to perform a delete operation that relies on dynamic values provided to a ForEach controller. I am using JSON JMESPath to obtain the count of occurrences needed for generating these dynamic values. However, when I directly use this count in the ForEach controller’s “End index for loop (inclusive)” field, the loop only runs a few times and then fails for the remaining iterations.
Here is an example of the JSON response:
"companyRecords" :[
{
"employeeRecord": [
{
"employeeid" : "1234",
"employeename" : "Joe",
},
{
"employeeid" : "5678",
"employeename" : "Matthew",
}
{
"employeeid" : "1120",
"employeename" : "David",
}
],
"joiningMonth" : "April",
"employmentType" : "FullTime"
}
],
The JMESPath expression in the HMESPath Extractor:
length(companyRecords[].employeeRecord[].employeeid)
The variable name being NoOfRecords.
In the current instance, this gives me a count of 3. I am using this as a varaiblenin the Foreach controller as below.
input variable prefix: employeeid
start index for loop (exclusive) : 1
End index for loop (inclusive) : ${NoOfRecords}
Output variable name: employeeid
The above foreach loop is working only for 2 iterations and not the third, I tried with the start index in the JMESPath being set to 0 and still it gives a 403 error.
Is there a way to get this to work? Thanks in advance!