Adding an .authorizationHeader as value/pair?

My request Works from Firefox RESTClient. See screenshot. The request needs a token called X-Token with value 1234asdf.

Request example:

— request —


Accept-Encoding: gzip,deflate

X-Token: 1234asdf

Host: ua.gaylord.nus

— response body —


“resultCode”: “SUCCESS”,

“errorCode”: null,

“errorMessage”: null,

“profile”: {

“fullName”: “TestFirstName TestMiddleName TestLastName”,

“memberships”: [ {

“name”: “UA Gold Partner”,

“number”: “123-456-123-123”,

“scanNumber”: “123-456-123-123”




However, in Gatling I try this:

val httpConf = http .baseURL([]( .acceptEncodingHeader("""gzip,deflate""") .authorizationHeader("""X-Token:1234asdf""") val scn = scenario("Scenario")

And get the same error as I get when removing the token from Firefox RESTCleient:


{"resultCode":"PERMANENT_ERROR","errorCode":"UNEXPECTED_SERVER_ERROR","errorMessage":"Missing header 'X-Token' for method parameter type [java.lang.String]"}


My questions is:

How do I add a token in Gatling as I do in Firefox RESTClient? I guess I need to spesify name=X-Toekn and value 1234asdf ? But what is the syntax?



Authorization is not a concept here, it’s the name of a HTTP header: Authorization.

So what you’re doing here is sending:
Authorization: X-Token:1234asdf

What you want here is to set a specific header named “X-Token”, so that would be:
.header(“X-Token”, “1234asdf”)

But when I do that I get the error in IntelliJ that .header connot be resolved. Se screendump.
Do I need to import something?


Ha sorry, that’s baseHeaders:

There’s room for improvement here. Working on it:

Ok thanks.
Then I need to upgrde my Gatling Version right. When this fix is shipped?

My pom states now:


No, you can use existing “baseHeaders”. Just that it will be deprecated in RC6 in favor of “headers” and will be removed in 2.1 (several months away).

Ok, but
.baseHeaders(“X-Token”, “1234asdf”)
does not work.
see the screenshot.



As the doc pointer I previously sent states, baseHeaders takes a Map.

baseHeaders(Map(“X-Token” → “1234asdf”))

Great, thank you! I was not certain how to state “a map”.
Works now.

We do our best to progressively add more examples for people who are not familiar with Scala syntax…
Doing our best…