I’m trying to insert an incrementing number into the URL I’m repeatedly querying (ie: product/1, product/2, product/3):
`
object CallProduct {
val callProduct = repeat(10, “i”) {
exec(http(“callProduct on port ${i}”)
.post("/product/${i}")
.headers(headers_0))
}
}
`
However, I have no product/0. Everything starts at 1. How do I increment ${i} by 1 or get the counter to start at 1? I’ve tried a number of ways, but I always get a NumberFormatException or compile error. Thanks in advance!
You’ll have to create a new attribute with translated value in an exec(function) or use functions everywhere instead of EL.
Thank you for your response. Can you point me in the direction of an example of how to use exec function that integrates with the exec method I had in my previous post to actually execute the post request? I don’t understand how I can have multiple exec calls that work with one another. The documentation for session and scenario do not explain how to use execs that are passed functions with those that are calling methods using dot notation. What I want to do is something like:
`
object CallProduct {
val callProduct = repeat(10, “i”) {
exec {
session=>
session.set(“i”,"${i}".toInt+1)
}
exec(http(“callProduct on port ${i}”)
.post("/product/${i}")
.headers(headers_0))
}
}
`
Obviously, this doesn’t work and I don’t know why. Thanks for your help!