0
votes

I'm trying to parse a response header value (which is a string) of one request into another method or function in gatling. Here is what I tried

val scn = scenario("DeviceAuth")
.feed(csvFeeeder)
.exec(http("Request1")
  .post("endpoint")
  .headers(headers_0)
  .formParam("key", "value")
  .check(headerRegex("header","pattern.*)").saveAs("value"))
  .check(status.is(401)))
object getHeader{
def authenticationHeader: String = {
val header: String = "${value}"
val s = header.split("")
     --so on and so forth--
}
}

So, when I tried to print the header value, it's just printed "${value}. How can we pass that value into my function?

1
Please use `${value}` instead "${value}"Eugene
@Eugene used ` ${value} ` in place of "${value}" Got an exception saying ${value} not foundkrish

1 Answers

0
votes

Please try this solution

val scn = scenario("DeviceAuth")
.feed(csvFeeeder)
.exec(http("Request1")
  .post("endpoint")
  .headers(headers_0)
  .formParam("key", "value")
  .check(headerRegex("header","pattern.*)").saveAs(value))
  .check(status.is(401)))
object getHeader{
def authenticationHeader: String = {
val header: String = `$value`
val s = header.split("")
     --so on and so forth--
}
}