Gatling / Scala - Post Request: Set StringBody value from variable

I have the following chain:

        val search= exec(repeat(products.size, "n"){
        feed(products.circular)
            .uniformRandomSwitch( //5
                exec(session => {session.set("searchBody", """{"productId":"${productID}","minPrice":"${minPrice}"}""")}),
                exec(session => {session.set("searchBody", """{"productId":"${productID}","category":"${category}"}""")})
            )
        .exec(
            http("/products")
                .post(appURL + "/search")
                .headers(jsonHeader)
                .body(StringBody("${searchBody}")).asJSON
                .check(status.is(200), responseTimeInMillis.lessThan("${expectedResponseTime}"))
        )
    })

I want to set into the variable searchBody the value of the body of my requests. But when I execute the requests i am getting the error:

i.g.h.a.ResponseProcessor - Request '/products' failed:status.find.is(200), but actually found 403

I think the error is how I am building the value of the body. The values of the variables are not printed in the string searchBody. Any idea?

https://gatling.io/docs/current/general/debugging/

may be helpful

在 2018年6月19日星期二 UTC+8上午6:38:06,roman…@gmail.com写道: