Facing issue while trying to pass parameter from first request to the header of the next. Could someone please let me know what am I doing wrong here?
Code:
`
package computerdatabase
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._
class Test1 extends Simulation {
val httpProtocol = http.baseUrl(“https://tabc.com”)
val httpProtocol_1 = http.baseUrl(“https://services.com”)
val header = Map(
“Content-Type” → “application/soap+xml;charset=UTF-8”,
“Connection” → “alive”,
“User-agent” → “Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0”)
val header_1 = Map(
“Authorization”->"${authToken}",
“actor”->“ISET”,
“log_token”->“LOG”,
“scope”->“read”,
“timestamp”->“123456789”
)
object pl{
val layer7 = scenario(“getauth”).exec(http(“GetAuthToken”)
.post("/oauth/token")
.body(StringBody("""{“client_id” : “123456”,
“client_secret” : “abc123456”,
“grant_type” : “client_credentials”}
“”")).asJSON.check(status.is(200)).check(jsonPath("$.access_token").saveAs(“authToken”)))
val pl1 = exec(http(“dental”)
.post("/dental/search")
.headers(header_1)
.body(StringBody("""<?xml version="1.0" encoding="utf-8"?>
123456
“”")))
}
val auth = scenario(“getauth”).exec(pl.layer7)
val pl1_1 = scenario(“claimsummary”).exec(pl.pl1)
setUp(auth.inject(rampUsers(1) during (1 seconds)).protocols(httpProtocol_1),
pl1_1.inject(nothingFor(10 seconds),
rampUsers(10) during (5 seconds)).protocols(httpProtocol))
}
`
Error:
value asJSON is not a member of io.gatling.http.request.builder.HttpRequestBuilder possible cause: maybe a semicolon is missing before
value asJSON’?
“”")).asJSON.check(status.is(200)).check(jsonPath("$.access_token").saveAs(“authToken”)))
^
15:19:49.866 [ERROR] i.g.c.ZincCompiler$ - one error found
15:19:49.867 [ERROR] i.g.c.ZincCompiler$ - Compilation crashed
sbt.internal.inc.CompileFailed: null
at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:242)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:111)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:90)
at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$3(MixedAnalyzingCompiler.scala:82)
`