# Extracting map from session and using inside headers()

**URL:** <https://community.gatling.io/t/extracting-map-from-session-and-using-inside-headers/2560>\
**Category:** Gatling (Open-Source)\
**Created:** [September 25, 2015, 3:38am UTC](https://community.gatling.io/t/extracting-map-from-session-and-using-inside-headers/2560 "2015-09-25T03:38:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish\_Rathore](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Ashish\_Rathore](https://community.gatling.io/u/Ashish_Rathore)\
**Post date:** [September 25, 2015, 3:38am UTC](https://community.gatling.io/t/extracting-map-from-session-and-using-inside-headers/2560/1 "2015-09-25T03:38:28Z")

</div>

Hello Folks,

I have a case where a session variable (a Map) need to be used for **http().headers(Map).**

Currently I get below compile error when trying to do so:

20:30:45.333 [ERROR] i.g.c.ZincCompiler$ - …/user-files/simulations/myserver2/DownloadFromServer.scala:138: Cannot prove that Char \<:\< (String, String).

20:30:45.333 [ERROR] i.g.c.ZincCompiler$ - .headers("${headersMap}".toMap[String, String])

Here is a snippet of code:

scenario(“Setup Call”)

.exec(Some\_Chain\_Populating\_Session\_Map)

.exec(

http(“Setup Call”)

.post(“[https://URL/](https://URL/)”)

.header(“someSimpleHeader”, session =\> custom\_header2(session))

.headers("${headersMap}".toMap[String, String]) \<\<\<\<\<\<------------------------- Error’d out line

)

})

If session Map is not possible, what are our options? Iterating over Map followed by adding “.header()” inside http() call?

Thanks,  
Ashish

---

<div class="post-metadata">

**Author:** ![Jian\_Guan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jian\_Guan](https://community.gatling.io/u/Jian_Guan)\
**Post date:** [June 14, 2019, 8:35am UTC](https://community.gatling.io/t/extracting-map-from-session-and-using-inside-headers/2560/2 "2019-06-14T08:35:09Z")

</div>

Hi ashisa:  
Do you resolve this issue? I suffer from it too.

Hoping your help.

---

<div class="post-metadata">

**Author:** ![Jian\_Guan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jian\_Guan](https://community.gatling.io/u/Jian_Guan)\
**Post date:** [June 14, 2019, 8:38am UTC](https://community.gatling.io/t/extracting-map-from-session-and-using-inside-headers/2560/3 "2019-06-14T08:38:04Z")

</div>

Hi Ashash:  
Have you resolve it? I suffer from it too.

Thanks

my code as follow:

```auto
object AuthenticationExec {

  val login =
      feed(csv("execFeeders/login.csv").batch.random)
      .exec{ session=>
        val rq = new LoginRq()
        val body = rq.getBody(session("loginType").as[String], session("user").as[String], session("password").as[String])
        val url = rq.getUrl()
        val headers = rq.getHeader().asScala.toMap
        session.set("body",body).set("url",url).set("header",header)
      }
      .exec(
        http(Thread.currentThread().getStackTrace()(2).getMethodName())
        .post("${url}")
        .headers("${header}".toMap[String,String])
        .body(StringBody("${body}")).asJson
        .check(status.is(201))
        .check(jsonPath("$.token").saveAs("User-Token")))
}

```

_The information in this e-mail and any attachments is confidential. It is intended solely for the addressee(s) named above. If you are not an intended recipient, please notify the sender and delete the message and any attachments from your system. Any use, copying or disclosure of the contents is unauthorised unless expressly permitted. Any views expressed in this message are those of the sender unless expressly stated to be those of OpenJaw. Virus checking of emails and attachments is the responsibility of the recipient and OpenJaw cannot accept responsibility for any loss or damage arising from the use of this email or attachments. OpenJaw Technologies Limited is a limited company registered in Ireland having registration number 353613 and registered office at Grattan Bridge House, 1 Ormond Quay Upper, Dublin 7._
