Jasper Slokker
Jasper Slokker

Reputation: 95

Make a Gatling Post request with basicAuth in Gatling

In my Gatling test I have this test:

  val HorizonPost: ChainBuilder = exec(
    http("Horizon Post")
      .post(getRouteInfoURI).basicAuth(s"${{EnvValues.RoadsApi_Username}}", s"${{EnvValues.RoadsApi_Password}}")
      .body(ElFileBody("bodies/horizonPost.json")).asJson
      .check(status.is(200))
  )

It seems that It has problems with the 'current_timestamp' and gives this error:

    body=
The request content was malformed:
Text '{{$current_timestamp}}' could not be parsed at index 0

The JSON file is:

 "locationTimestamp": "{{$current_timestamp}}",

Can someone explain what I need to change? I'm relatively new to Gatling.

Upvotes: 0

Views: 478

Answers (2)

Jasper Slokker
Jasper Slokker

Reputation: 95

We solved this problem by storing the timestamp in a separate csv file, the only problem is that it is not the current_timestamp. Thanks for the possibilities.

Upvotes: 0

Stéphane LANDELLE
Stéphane LANDELLE

Reputation: 6608

If you're trying to use Scala string interpolation, the correct syntax is s"${foo}", not s"${{foo}}".

If you're trying to use Gatling Expression Language, the correct syntax is "${foo}" (no s), not s"${{foo}}".

Upvotes: 1

Related Questions