Mixing params and body(RawFileBody(...))

Hello,

When using the recorder to convert a HAR file, it generates code that uses files as post inputs.
I know I can move all the parameters to many params declarations, but only one of them changes, the rest is the same. So ideally I would like to do:

.exec(http(“request_201”)
.post("""/queries""")
.headers(headers_201)
.params(“variable_field”, “${my_variable}”)

.body(RawFileBody(“RecordedSimulationTemp2_request_201.txt”)))

But it ends up ignoring any params declaration, only using the raw file.

Thanks,
Alejandro

That is technically not possible as the parameters are sent in the body.

.queryParams(“variable_field”, “${my_variable}”)

.body(RawFileBody(“RecordedSimulationTemp2_request_201.txt”)))

An alternative is to use the query parameters. Is this what you actually meant ?

cheers
nicolas

Thank you for your reply. I want to remove the variable=constant from the raw body, and define it programatically, but keeping the rest of the parameters in the raw body. Using this:

.exec(http(“request_201”)
.post("""/queries""")
.headers(headers_201)
.queryParams(""“authenticity_token”"", “”"${csrf_token}""")
.body(RawFileBody(“RecordedSimulationTemp2_request_201.txt”)))

Results in a compilation error:

GATLING_HOME is set to /home/ifrid/Descargas/gatling-charts-highcharts-2.0.0-M3a
16:47:04.452 [ERROR] i.g.a.ZincCompiler$ - /home/ifrid/Descargas/gatling-charts-highcharts-2.0.0-M3a/user-files/simulations/RecordedSimulationTwo.scala:108: value queryParams is not a member of io.gatling.http.request.builder.PostHttpRequestBuilder
possible cause: maybe a semicolon is missing before `value queryParams’?
16:47:04.455 [ERROR] i.g.a.ZincCompiler$ - .queryParams(""“authenticity_token”"", “”"${csrf_token}""")
16:47:04.464 [ERROR] i.g.a.ZincCompiler$ - ^
16:47:04.604 [ERROR] i.g.a.ZincCompiler$ - one error found
Exception in thread “main” Compilation failed

I could use latest gatling from github, but I don’ t know how to build the directory full of JARs (“sbt test” passes).

Sorry, queryParam(), not queryParams().

To use a SNAPSHOT version of Gatling, you can just download the package from here: https://oss.sonatype.org/content/repositories/snapshots/io/gatling/highcharts/gatling-charts-highcharts/2.0.0-SNAPSHOT/

Regards

Thanks, it worked with queryParam!

Sorry for asking a question in an old thread. I’m facing the same issue where in I want to change only one parameter and the rest recorded by Gatling HTTP recorder sent in body as Raw File. I’m wondering how queryParam is equivalent to sending the data through request body. I thought quesry params are not encryptable and used only for GET requests and formParams should be used for POST requests. But gatling ignores formParam values when using raw file body. Your thoughts on this please.