# missing parameter type compilation errors while building headers dynamically using a function.

**URL:** <https://community.gatling.io/t/missing-parameter-type-compilation-errors-while-building-headers-dynamically-using-a-function/3845>\
**Category:** Gatling (Open-Source)\
**Created:** [July 24, 2017, 4:40pm UTC](https://community.gatling.io/t/missing-parameter-type-compilation-errors-while-building-headers-dynamically-using-a-function/3845 "2017-07-24T16:40:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dinesh\_Reddy](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@Dinesh\_Reddy](https://community.gatling.io/u/Dinesh_Reddy)\
**Post date:** [July 24, 2017, 4:40pm UTC](https://community.gatling.io/t/missing-parameter-type-compilation-errors-while-building-headers-dynamically-using-a-function/3845/1 "2017-07-24T16:40:12Z")

</div>

Hi All,

I am trying to build the header values as map in a function, as there is a dynamic value I need to use. But I am getting the compilation errors - “ **missing parameter type** ” at “.**headers(Session =\> getBrowseAppsHeader(Session(“mindevice”).as[String].toInt, Session(“maxdevice”).as[String].toInt))**”. Following is the code snippet which gives the compilation errors. Can any one help me on this?

def getBrowseAppsHeader(minDevice:Int, maxDevice:Int): Map[String, String] = {

val rnd = new scala.util.Random  
val AndDeviceRange = minDevice to maxDevice  
val AndDeviceID = AndDeviceRange(rnd.nextInt(AndDeviceRange.length))

val BrowseAppsHeader: Map[String, String] = Map(  
“deviceid” → AndDeviceID.toString(),  
“devicemodel” → DEVICEMODEL,  
“devicename” → DEVICENAME,  
“osversion” → OSVERSION,  
“Content-Type” → contentType,  
“Accept” → JSonResponseType,  
“userid” → EMMPerfConfig.guserid,  
“platformid” → “ANDROID”  
)  
BrowseAppsHeader  
}

val execBrowseApps = exec(http(“Browseapps”)  
.post("${tenantname}%sdevice/rest/browse/apps".format(context))  
.headers(Session =\> getBrowseAppsHeader(Session(“mindevice”).as[String].toInt, Session(“maxdevice”).as[String].toInt))

.body(StringBody(browseAppReqBody))  
.check(status.is(200))  
.check(jsonPath("$.opstatus").is(“0”))

---

<div class="post-metadata">

**Author:** ![vu.nguyen](https://avatars.discourse-cdn.com/v4/letter/v/ba9def/32.png) [@vu.nguyen](https://community.gatling.io/u/vu.nguyen)\
**Post date:** [July 25, 2017, 5:57pm UTC](https://community.gatling.io/t/missing-parameter-type-compilation-errors-while-building-headers-dynamically-using-a-function/3845/2 "2017-07-25T17:57:49Z")

</div>

What you try to build to my understanding is not allowed currently. The “headers” does not accept Expression[Map[String, String]] by definition:  
[http://gatling.io/docs/current/http/http\_request/#headers](http://gatling.io/docs/current/http/http_request/#headers)

[https://github.com/gatling/gatling/blob/a3d2f4b44ac292931599a1b6c4cb72515d7a4e96/gatling-http/src/main/scala/io/gatling/http/protocol/HttpProtocolBuilder.scala#L85-L86](https://github.com/gatling/gatling/blob/a3d2f4b44ac292931599a1b6c4cb72515d7a4e96/gatling-http/src/main/scala/io/gatling/http/protocol/HttpProtocolBuilder.scala#L85-L86)

`headers(newHeaders: Map[String, String])`

You may find alternative solution in a recent post about this topic:[https://groups.google.com/forum/#!msg/gatling/YEsQ\_YNo0eE/KfARQf3pAwAJ](https://groups.google.com/forum/#!msg/gatling/YEsQ_YNo0eE/KfARQf3pAwAJ)

Or file a feature change request for Stephan et team?

---

<div class="post-metadata">

**Author:** ![Dinesh\_Reddy](https://avatars.discourse-cdn.com/v4/letter/d/e36b37/32.png) [@Dinesh\_Reddy](https://community.gatling.io/u/Dinesh_Reddy)\
**Post date:** [July 30, 2017, 8:56am UTC](https://community.gatling.io/t/missing-parameter-type-compilation-errors-while-building-headers-dynamically-using-a-function/3845/3 "2017-07-30T08:56:47Z")

</div>

Thank you for your reply. I have actually tried this as well, but got the same error. Currently I modified the code as follows, as a workaround.

def getBrowseAppsHeader(): Map[String, String] = {

val BrowseAppsHeader: Map[String, String] = Map(  
“devicemodel” → DEVICEMODEL,  
“devicename” → DEVICENAME,  
“osversion” → OSVERSION,  
“Content-Type” → contentType,  
“Accept” → JSonResponseType,  
“userid” → EMMPerfConfig.guserid,  
“DEVICE\_PLATFORM\_ID” → “ANDROID”  
)  
BrowseAppsHeader  
}

def getDynamicDevice(minDevice:Int, maxDevice:Int): String = {

val rnd = new scala.util.Random  
val AndDeviceRange = minDevice to maxDevice  
val AndDeviceID = AndDeviceRange(rnd.nextInt(AndDeviceRange.length))

s"""${AndDeviceID}"""  
}

.header(“deviceid”, Session =\> getDynamicDevice(Session(“mindevice”).as[String].toInt, Session(“maxdevice”).as[String].toInt))  
.headers(getBrowseAppsHeader())

Thank you  
Dinesh
