# Error : Failed to build request: No attribute named 'access' is defined

**URL:** <https://community.gatling.io/t/error-failed-to-build-request-no-attribute-named-access-is-defined/8322>\
**Category:** Gatling (Open-Source)\
**Created:** [September 25, 2023, 8:37am UTC](https://community.gatling.io/t/error-failed-to-build-request-no-attribute-named-access-is-defined/8322 "2023-09-25T08:37:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![harshit](https://avatars.discourse-cdn.com/v4/letter/h/c57346/32.png) [@harshit](https://community.gatling.io/u/harshit)\
**Post date:** [September 25, 2023, 8:37am UTC](https://community.gatling.io/t/error-failed-to-build-request-no-attribute-named-access-is-defined/8322/1 "2023-09-25T08:37:00Z")

</div>

Hi Team,  
I am trying to generate bearer token dynamically and paas it to other end points but getting error

> Expenses - fetchsetupdata: Failed to build request: No attribu 24 (100.0%)  
> te named ‘access’ is defined

Code:

```auto
private var token = ""
  val auth = exec(getAuthToken)

  def getAuthToken() =
    exec(
      http("get OAuth Req")
        .get("{OUR-URL}/tokenRelay?username=${loginname}")
        .check(bodyString.saveAs("access"))
        .check(status is 200))
        .exec{session => { token = session("access").as[String]
        session}}

  val authorization3 = Map("authorization" -> "Bearer ${access}")

  def fetchSetupData () =
    exec(
      http("Expenses - fetchsetupdata")
        .post(url+"/resources/v0/expenses/action/fetchSetupData")
        .header("content-type","application/vnd.oracle.adf.action+json")
        .headers(authorization3)
        .headers(restFrameworkVersion)
        .body(ElFileBody("bodies/fetchSetupData.json")).asJson
        .check(status.in(200))
    )

```

Code from simulation file:

```auto
val expensesScenario = scenario("Expenses - Scenario")
    .during(Configuration.duration) {
      exitBlockOnFail(
        group ("load-test") {
          exec(
            pace(Configuration.paceFrom,Configuration.paceTo),
            feed(expenseIds), feed(expenseAttendeeIds)
            .exec(

              expensesChain.fetchSetupData()
            )
          )
	}
      )
    }

```

Tried many things but onthing or the other is going wrong. Any help will be appriciated

---

<div class="post-metadata">

**Author:** ![GatlingPete](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gatlingpete/32/1167_2.png) [@GatlingPete](https://community.gatling.io/u/GatlingPete)\
**Post date:** [September 25, 2023, 9:40am UTC](https://community.gatling.io/t/error-failed-to-build-request-no-attribute-named-access-is-defined/8322/2 "2023-09-25T09:40:42Z")

</div>

Hello Harshit,

When creating a post it’s really important to provide as much information as possible so you can help us help you.

What kind of authentication are you going for? One authentication by user or global token?  
What did you try?

What’s your Gatling version?

Looking at the screenshot, the error you are getting is: `No attribute named 'access' is defined` .

This suggests that you aren’t saving the `token` from the header `access`.

Look closely at the HTTP request - especially the headers, and check that the header exists as you expect. You could use Chrome Dev Tools or any HTTP proxy for this.

All the best,  
Pete

---

<div class="post-metadata">

**Author:** ![harshit](https://avatars.discourse-cdn.com/v4/letter/h/c57346/32.png) [@harshit](https://community.gatling.io/u/harshit)\
**Post date:** [September 26, 2023, 8:08am UTC](https://community.gatling.io/t/error-failed-to-build-request-no-attribute-named-access-is-defined/8322/3 "2023-09-26T08:08:24Z")

</div>

We are trying to do global authentication using bearer token.  
Gatling version \<gatling.version\>3.6.1\</gatling.version\>  
Actually we were able to do authentication this way in \<gatling.version\>3.0.0\</gatling.version\>  
But after version upgrade we started getting this error.

Yes headers exist as expected

---

<div class="post-metadata">

**Author:** ![GatlingPete](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/gatlingpete/32/1167_2.png) [@GatlingPete](https://community.gatling.io/u/GatlingPete)\
**Post date:** [September 26, 2023, 9:31am UTC](https://community.gatling.io/t/error-failed-to-build-request-no-attribute-named-access-is-defined/8322/4 "2023-09-26T09:31:19Z")

</div>

Thanks Harshit,

Would you mind upgrading to the latest version of Gatling? As a rule here we only provide assistance on the latest version of Gatling here and 3.6.1 is over 2 years old. Anything that old we can’t really create a reproducer on our end.

All the best,  
Pete

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [October 26, 2023, 9:31am UTC](https://community.gatling.io/t/error-failed-to-build-request-no-attribute-named-access-is-defined/8322/5 "2023-10-26T09:31:35Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
