Passing Multiple Headers in Gatling

715 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 best solutions below

3
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.