In below code, i am capturing response in UserId variable. I am failing to pass this UserId variable in next request, it is throwing errors.
.exec(http(“Create USer”)
.post(""“Urlxxxx”"")
.body(StringBody("""{“email”:“sample@gmail.com”}"""))
.check(headerRegex(“Location”, “(.*)”).saveAs(“userId”))) // capturing dynamic value in UserId variable
// System.out.println("UserID: " + userId+ “\n”) // i tried to print like this, no use
//exec(
(s:Session) => println(s.getAttribute("
userId")) // tried this also, but no use to conform what i am getting in UserId
)
/**************** next request*******************************/
val scn1 = scenario(“Identity”)
.exec(http(“request_0”)
.post("""/urlxxxx""")
.body(StringBody("""{
“username”:“anitha156”,
“password”:“anitha56”,
“userId”:"${userId}", // passing that userid in this request.
}""")))
When i used ".check(currentLocationheaderRegex(“Location”, “(.*)”).saveAs(“userId”)))"i got below error message.
[ERROR] i.g.a.ZincCompiler$ - C:\Users\anitha\Desktop\gatling-chart
s-highcharts-2.0.1\user-files\simulations\CreateUser.scala:128: too many arg
uments for method apply: (v1: io.gatling.core.session.Session => io.gatling.core
.validation.Validation[String])io.gatling.http.check.url.CurrentLocationRegexChe
ckBuilder[String] with io.gatling.http.check.url.CurrentLocationRegexOfType in t
rait Function1
In documentation i saw below syntax , if i use this , where should I save my userId value?
__currentLocationRegex("http://foo.com/bar?(.*)=(.*)").ofType[(String, String)]__
And one more point here, i am trying to pass this value to next request in same script, like ,"{userId}", But i am getting "No attribute name userId is found.
So, can you please help me on how to pass this value to next request?
Thanks for your help in advance.
Regards,
Anitha.