trouble calling 280 rest services randomly, this example uses Basic Auth

I need to randomly invoke up to 280 services 40 different transaction servers each with 7 different programs to invoke.
If I hardcode 1 URI into the .post(…) it works for that one program.

.
If I try the code below, it does not work, Can I call the method createURL() inside the scenario definition and expect it to be different for each injection for each simulated browser?.
The URIs look like this:
/zosConnect/services/RTWService1p0?action=invoke
/zosConnect/services/RTWService1p1?action=invoke

/zosConnect/services/RTWService2p0?action=invoke


/zosConnect/services/RTWService3p5?action=invoke
.

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
import scala.util.Random
class RTWBasicx extends Simulation {
val browsers = 400
val rampUp = 100
val howManyTimes = 167
val regions = 20
val r = Random
val inuris = “https://x.x.x.x:9443” // x’s so i do not give away any IP addresses

val httpConf = http

.baseURL(inuris) // Here is the root for all relative URLs
.acceptHeader(“application/xml,application/jsonq=0.9,/;q=0.8”) // Here are the common headers
.doNotTrackHeader(“1”)
.acceptLanguageHeader(“en-US,en;q=0.5”)
.acceptEncodingHeader(“gzip, deflate”)
.userAgentHeader(“Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0”)

val headers_10 = Map(“Content-Type” → “”“application/x-www-form-urlencoded”"")

var scn = scenario(“RTWServlet4”).repeat(howManyTimes) { // A scenario is a chain of requests and pauses
exec(http(“request_1”)

.post(createURL())
.headers(headers_10)
.basicAuth(“xxxxxx”, “xxxxxx”)) // x’s so i do not give away userid and password
.pause(1)
}
//setUp(scn.inject(atOnceUsers(10)).protocols(httpConf))
setUp(scn.inject(rampUsers(browsers) over(rampUp seconds)).protocols(httpConf))

def createURL() : String = {
var URL = “/zosConnect/services/RTWService” + (r.nextInt(regions) + 1) + “p” + r.nextInt(7)+ “?action=invoke”
println(URL)
return URL
}
}

Thank You
H. Michael Everett

Hi Harold,

The problem is that you’re passing a String to post, not a function, so createURL() is only called once, when the Simulation is created.
If you want createURL() to be invoked on every request, you have to pass a function: http://gatling.io/docs/2.0.3/session/expression_el.html#expression-language

What you want is .post(session => createURL())