# Login - Body doesnt have correlated value instead it is passing param name of correlation

**URL:** https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748
**Category:** Gatling (Open-Source)
**Created:** [May 11, 2022, 2:08pm UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748 "2022-05-11T14:08:36Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![rekha](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rekha](https://community.gatling.io/u/rekha)
#### Post date: [May 11, 2022, 2:08pm UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/1 "2022-05-11T14:08:37Z")

</div>

Hello All,

As part of application i correlated CSRF token. I passed it in the login request.

**Correlation:**  
check(regex("""\_csrf" value="([^"]\*)"""")  
.saveAs(“Corrcsrf”))

I passed those value like this : .formParam("\_csrf", “${Corrcsrf}”)

When i execute, I got 403 forbidden error. Then i checked the log, I was surprised to see values were not replaced instead strings are replaced.

body:FormUrlEncodedRequestBody{contentType=‘application/x-www-form-urlencoded’, charset=UTF-8, content=\_csrf=%24%7BCorrcsrf%7D&username=RESUNDA&pingRefId=true&pingResume=%24%7Bpingresume%7D%2Fresume%2Fas%2Fauthorization.ping&instance=default&password=123123}

Can anyone please suggest me.

Regards  
Rekha S

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [May 11, 2022, 3:03pm UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/2 "2022-05-11T15:03:01Z")

</div>

Hello,

Please follow the [requirements listed here](https://community.gatling.io/t/how-to-ask-a-question/6538).

You don’t say that you have checked you’re using the latest version, if you’re using the Java or the Scala DSL, etc. As is, it’s impossible to help you.

---

<div class="post-metadata">

### Author: ![rekha](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rekha](https://community.gatling.io/u/rekha)
#### Post date: [May 11, 2022, 5:19pm UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/3 "2022-05-11T17:19:04Z")

</div>

Java Version : 11  
Scala : 3.1.2  
Gatling : 3.7.6  
Maven : 3.8.5  
IntelliJ Idea : IntelliJ IDEA 2022.1

Let me know if you need any more information.

---

<div class="post-metadata">

### Author: ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)
#### Post date: [May 11, 2022, 6:06pm UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/4 "2022-05-11T18:06:54Z")

</div>

> [@rekha](#):
>
> Scala : 3.1.2

Weird, I don’t think gatling is compatible with scala 3.

> [@rekha](#):
>
> Let me know if you need any more information.

You didn’t tell if you use the Java or the Scala DSL (as we manage both now).

Did you try with the `"#{Corrcsrf}"` syntax? (See [Gatling Expression Language](https://gatling.io/docs/gatling/reference/current/core/session/el/)), because `$` is deprecated.

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [May 11, 2022, 7:38pm UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/5 "2022-05-11T19:38:31Z")

</div>

Have you messed up the imports?

You **MUST** have the [same imports as in our documentation](https://gatling.io/docs/gatling/tutorials/quickstart/#gatling-scenario-explained):

```nohighlight
import io.gatling.core.Predef._
import io.gatling.http.Predef._

```

Typically, don’t let IntelliJ “optimize” your imports and actually break things.

---

<div class="post-metadata">

### Author: ![rekha](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rekha](https://community.gatling.io/u/rekha)
#### Post date: [May 16, 2022, 4:51am UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/6 "2022-05-16T04:51:33Z")

</div>

Hello sbrevet,

I changed the scala version to 2.13. I changed to “#{Corrcsrf}” still no luck.

---

<div class="post-metadata">

### Author: ![rekha](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rekha](https://community.gatling.io/u/rekha)
#### Post date: [May 16, 2022, 4:52am UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/7 "2022-05-16T04:52:28Z")

</div>

Yes I am using the same lib whatever you mentioned. (not allowing IDE to optimize)

---

<div class="post-metadata">

### Author: ![rekha](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rekha](https://community.gatling.io/u/rekha)
#### Post date: [May 16, 2022, 5:08am UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/8 "2022-05-16T05:08:22Z")

</div>

I am using scala DSL

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [May 16, 2022, 7:16am UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/9 "2022-05-16T07:16:09Z")

</div>

Here’s what I did:

- `git clone https://github.com/gatling/gatling-maven-plugin-demo-scala.git`
- uncommented `TRACE` logger in `logback-test.xml`
- changed `BasicSimulation` to:

```auto
package computerdatabase

import io.gatling.core.Predef._
import io.gatling.http.Predef._
import scala.concurrent.duration._

class BasicSimulation extends Simulation {

  val httpProtocol = http
    .baseUrl("http://computer-database.gatling.io") // Here is the root for all relative URLs
    .acceptHeader("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") // Here are the common headers
    .acceptEncodingHeader("gzip, deflate")
    .acceptLanguageHeader("en-US,en;q=0.5")
    .userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0")

  val scn = scenario("Scenario Name")
      .exec(session => session.set("foo", "bar"))
      .exec(http("request_10")
        .post("/computers")
        .formParam("""name""", """#{foo}""") // EXPECT bar
        .formParam("""introduced""", """2012-05-30""")
        .formParam("""discontinued""", """""")
        .formParam("""company""", """37"""))

  setUp(scn.inject(atOnceUsers(1)).protocols(httpProtocol))
}

```

- ran `mvn clean gatling:test`
- observed that the substitution was properly triggered in the logs:

```auto
body:FormUrlEncodedRequestBody{contentType='application/x-www-form-urlencoded', charset=UTF-8, content=name=bar&introduced=2012-05-30&discontinued=&company=37}

```

So as far as I can tell, everything works as expected. As I already request in this thread, please provide a reproducer.

---

<div class="post-metadata">

### Author: ![rekha](https://avatars.discourse-cdn.com/v4/letter/r/6a8cbe/32.png) [@rekha](https://community.gatling.io/u/rekha)
#### Post date: [May 16, 2022, 10:58am UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/10 "2022-05-16T10:58:35Z")

</div>

I deleted the simulation and recreated freshly because in IDE, scala 3.X version was configured. When I recreated, I could change to scala 2.X. It is mainly because of scala version.

Now it is working fine 🙂

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [May 16, 2022, 11:27am UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/11 "2022-05-16T11:27:57Z")

</div>

Great, thanks four your feedback!

---

<div class="post-metadata">

### Author: ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)
#### Post date: [May 16, 2022, 11:28am UTC](https://community.gatling.io/t/login-body-doesnt-have-correlated-value-instead-it-is-passing-param-name-of-correlation/6748/12 "2022-05-16T11:28:02Z")

</div>


