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

1,647 views
Skip to first unread message

Alejandro Pulver

unread,
Apr 23, 2014, 2:52:31 PM4/23/14
to gat...@googlegroups.com
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

Nicolas Rémond

unread,
Apr 23, 2014, 3:33:00 PM4/23/14
to gat...@googlegroups.com
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


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alejandro Pulver

unread,
Apr 23, 2014, 3:51:03 PM4/23/14
to gat...@googlegroups.com
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).


--
You received this message because you are subscribed to a topic in the Google Groups "Gatling User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gatling/MrJoM_dFgNc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gatling+u...@googlegroups.com.

Nicolas Rémond

unread,
Apr 23, 2014, 3:54:21 PM4/23/14
to gat...@googlegroups.com
Sorry, queryParam(), not queryParams().

Nicolas Rémond

unread,
Apr 23, 2014, 3:55:21 PM4/23/14
to gat...@googlegroups.com
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

Alejandro Pulver

unread,
Apr 25, 2014, 11:56:21 AM4/25/14
to gat...@googlegroups.com
Thanks, it worked with queryParam!

Mahesh

unread,
May 17, 2016, 6:47:18 AM5/17/16
to Gatling User Group
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.
Reply all
Reply to author
Forward
0 new messages