Unable to refer new file and use it in Post request, created during Gatling test execution

Hi All,

With reference to this issue https://groups.google.com/g/gatling/c/IC0-fGXxxLw.
I found an workaround but facing the below issue

Initial issue

  1. For a Post request server can only accept the Raw format.
  2. Hence used the .body(RawFileBody(“request-bodies/testt”)) in which substitution isn’t possible and values are getting passed as such.

I need to pass the request with dynamic substituted values, hence used the below workaround.

Workaround

  1. Created a raw file test with original correlated variables inside it
  2. Opened the raw file test and replaced the correlated variables with the actual values from server.
  3. Then copied the final content and set it into a session and copied the update value with substituted values from server into a new file called testt.

Issue

  1. When I run the script for the first time there won’t be any file name testt inside the request bodies folder and hence that particular request isn’t getting triggered.

Could you please tell is there anyway to access the created file during runtime?

Regards,
Aravind G

For a Post request server can only accept the Raw format.

This doesn’t make sense. There’s no such “raw” format.RawFileBody is only an optimization for sending bodies that don’t need to be modified.

Opened the raw file test and replaced the correlated variables with the actual values from server.

So this means you’ve used a text editor to edit your request body, meaning your content is text, not binary.
Then why don’t you use ElFileBody?

Hi Stephane,

Thanks for the solution.

I retried the same request with ElFilebody and its working seamlessly now without any issues.

I found this might me be the reason for it.

Previously I tried as .body(ElFileBody(“request-bodies/xmls”)).asXml - It threw 500 error ( which was the previous case )
Now I again I tried as .body(ElFileBody(“request-bodies/xmls”)) - Its working fine now. ( without appending .asJson or .asXml)

Regards,
Aravind G