Unable to post request body

Hi Stephanie,

I’m trying to post a request along with JSON body using gatling. However, the body is not getting attached with request.
I know this for sure because expected response with request body and without it is different.
Here is my code:-

class RecordedSimulation extends Simulation {

 val httpProtocol = http
  .baseURL(url)
  .inferHtmlResources()

 val headers_0 = Map("Origin" -> "chrome-extension://aejoelaoggembcahagimdiliamlcdmfm")

    val uri1 = "abc.com"

 val scn = scenario("RecordedSimulation")
  .exec(http("request_0")
   .post("/abc/efg")
   .headers(headers_0)
   .body(RawFileBody("RecordedSimulation_0000_request.txt"))
   .basicAuth("uid","pwd")
   .check(bodyString.is(RawFileBody("RecordedSimulation_0000_response.txt"))))

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

Hi All,

Any help would be highly appreciated.

Thanks,
Anuja

Hi Anuja,

You have used bodyString.is(RawFileBody(“RecordedSimulation_0000_response.txt”). I had the same case and I used JSON file instead of text.

Here is my code

exec(http(“Query (direct)…”)
.postnode)
.body(ELFileBody(“payloads/elastic_search_query.json”)).asJSON

Thanks,
Vrushalee Ajotikar

Correction: ELFileBody → ElFileBody

(L is lowercase in El)