Passing Multiple Headers in Gatling

719 views Asked by At

Im new to Gatling tool, trying to pass multiple header value from another file but im facing error while compiling.

Code:

val header0 = List(Map(
    "Ocp-Apim-Subscription-Key" -> TestParameters.Keyvalue,
    "UserId" -> TestParameters.UserID
  ))

Error:

ingInformation.scala:22:13: type mismatch;
 found   : scala.collection.immutable.Map[String,java.io.Serializable]
 required: Map[String,String]
                        .headers(header0)
                                 ^
1

There are 1 answers

3
Stéphane LANDELLE On BEST ANSWER

Why do you make header0 a List[Map[String, String]]?

It should be a Map[String, String]:

val header0 = Map(
  "Ocp-Apim-Subscription-Key" -> TestParameters.Keyvalue,
  "UserId" -> TestParameters.UserID
)

Also, as explained in the documentation, header values must be Strings. So if TestParameters.Keyvalue or TestParameters.UserID are anything else, such as numbers, you must convert them, eg with toString.