0
  class PostRequest extends Simulation {

  val httpProtocol = http
  .baseUrl("https://myurl.com")
  .inferHtmlResources()
  .acceptHeader("text/html,...v=b3")
  .acceptEncodingHeader("gzip, deflate")
  .acceptLanguageHeader("en-GB,....")
  .upgradeInsecureRequestsHeader("1")
  .userAgentHeader("Mozilla/5.0 ....Safari/537.36")

  val uuid = Iterator.continually(Map("val" -> java.util.UUID.randomUUID.toString()))

  val scn = 
  exec(_.set("uuid",uuid))
  scenario("PostRequest")
    .feed(uuid)
    .exec(http("request_0")
    .post("/path/")
    .body(StringBody("""
          {
              "Id": "${uuid}",
              "one": 
                {
                  "id": "${uuid}",
                  "channel": "EMAIL",
                  "timeStamp": "2018-05-01-22.23.23.123456",
                }
    }
  """))
     )

  setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
    }

while compiling, i am getting error

value inject is not a member of io.gatling.core.structure.ChainBuilder
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)

1 Answer 1

0

It's because your scn holds the value of exec(_.set("uuid",uuid)), which is a ChainBuilder instance, which you can't call inject on. Some curly brackets solve the problem, like this:

  val scn = {
    exec(_.set("uuid", uuid))
    scenario("PostRequest")
      .feed(uuid)
      .exec(http("request_0")
        .post("/path/")
        .body(StringBody(
          """
            {
              "Id": "${uuid}",
              "one":
                {
                  "id": "${uuid}",
                  "channel": "EMAIL",
                  "timeStamp": "2018-05-01-22.23.23.123456",
                }
            }
          """
        ))
      )
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.