Hi folks. I’m new to Gatling and to Scala - love the tool so far!. I’ve got an issue with my scenario when I try to use a pre-defined string val inside of my request body. In the code below, I define “list” and attempt to use it the step “add_collaborators” which results in “[ERROR] i.g.h.a.HttpRequestAction - No attribute named ‘list’ is defined”
What simple thing am I missing?
object upload {
val list: String = “”"{“email":"user1@test.company.com”},{“email":"user2@test.company.com”},{“email":"user3@test.company.com”}"""
val name: Expression[String] = (session: Session) => s"""{“name”:"${ThreadLocalRandom.current.nextInt(100000).toString}", “parentId”:“0” }"""
val scn = scenario(“End to End”)
.exec(
http(“get_token”)
.post(“http://url.company.com/api/oauth/token?grant_type=password&client_id=client1&client_secret=secret1&username=user76@test.company.com&password=password”)
.body(StringBody("{}"))
.check(status.is(200))
.check(jsonPath(".access_token").find.saveAs(“token”)))
.exec(
http(“get_key”)
.post(“http://url.company.com/api/v1/keys”)
.headers(headers_1)
.header(“Authorization”, “Bearer ${token}”)
.body(StringBody("""{}"""))
.check(status.is(200))
.check(jsonPath(“keys[0].id”).find.saveAs(“keyId”)))
.exec(
http(“create_folder”)
.post(“http://url.company.com/api/v1/collections”)
.headers(headers_1)
.header(“Authorization”, “Bearer ${token}”)
.body(StringBody(name))
.check(status.is(200))
.check(jsonPath(“id”).find.saveAs(“collectionId”)))
.exec(
http(“add_collaborators”)
.put(“http://url.company.com/api/v1/collections/${collectionId}”)
.headers(headers_1)
.header(“Authorization”, “Bearer ${token}”)
.body(StringBody("""{“id”:"${collectionId}",“collaborators”:{“recurse”:true,“add”:[${list}],“remove”:[]},“accessControls”:{“add”:[],“remove”:[]}}"""))
.check(status.is(200))
.check(jsonPath(".id").find.saveAs(“objectId”)))
etc…