Using feeders to construct a StringBody (2.0.0-M3a)

Okay, I’ve got another feeder/http POST body question. Thank you for all of your help so far - Gatling is an awesome tool, and I feel like I’m so close to getting it to work for our project.

I’m continuing to work on my registration load test, and now I’m running into the following issue when attempting to use a feeder to generate my JSON POST body - some lines don’t seem to be correctly handling double quotes in my CSV file. (Of three requests, one worked, two mysteriously didn’t.)

Relevant script pieces:
val userData = csv(“test.csv”).queue

val httpConf = http.baseURL(“”)

val scn = scenario(“Register user”)
http(“POST registration”)
.body(StringBody("""{“username”:${username}, “email”:${email}, “imei”:${imei}, “gcmId”:${gcmId}, “age”:${age},“albumSelection”:${albumSelection},“latitude”:${latitude},“longitude”:${longitude},“emailOptIn”:${emailOptIn},“termsOptIn”:${termsOptIn} }""")))

My CSV file looks like this:


It seems like everything is correct there, but when I run with logging turned on, I see the following messages:

Session(Register user,1,Map(latitude → 65, email → “”, username → tester7317165156", imei → “999997317165156”, age → “59”, longitude → 176, termsOptIn → true, emailOptIn → true, gcmId → “7317165156”, albumSelection → “clean”),1382385464346,0,List(),List(KO),List(),List())


Except if gmail did something funny with your original message, it seems your csv file is still messed up: double quotes inside a field have to be escape, and the whole field has to be surrounded with double quotes:

  • "“tester7105408553"” => bad
  • "“tester7105408553"” => good
    We use opencsv underneath, and it silently does weird stuff with malformed csv.

Anyway, why don’t you handle JSON string value quotes inside your JSON template?

You csv file would look like:


and your template like this:


That totally did the trick - I based the “double double quotes” off of some random CSV documentation I found, but your solution is better and more elegant, and works, to boot.

Thanks again for the prompt responses, much appreciated.


Was glad to help :slight_smile:

Have fun!