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

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:

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:

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

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

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

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

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