Reading payload from tsv file

Hi,

I am new to Gatling. I am writing a test scenario where I want to read payload for each of the POST request from a tsv file. My tsv file looks something like this:

flags

{"“payload”: {“Id”: “D85B24305BA511E3949A0800200C0000”,“a1”: “5A0C96845BA611E3949A0800200C0000”,“a2”: “S12”,“a3”: “S22”,“a4”: “INTERNAL”"}}

My scenario code looks like this:

val scn = scenario(name)

.feed(tsv(fileName).circular)

.exec(

http(name)

.post(url)

.body(StringBody("${flags}"))

.asJSON

.headers(headers)

.check(status is 200)

But I am getting 400 bad request. Am I doing anything wrong?

You probably didn’t properly escaped your JSON body according to the CSV spec: http://tools.ietf.org/html/rfc4180#section-2
See 2.4 to 2.6.

If your JSON is { “foo”: “bar” }, then you have to write in your CSV so it’s properly decoded: “{ “foo”: “bar” }”

FYI, there’s a new feature that let one perform a simple split instead of a full CSV parsing: https://github.com/excilys/gatling/issues/1937
Available on latest snapshot only.

So looks like it is able to read the file (console log shows so) but I am not sure if it is setting it properly in the request. I tried using

param is ONLY for form upload.
What you need is probably body.

Then, please take my previous explanations into account.

Escape character "" helped. Thank you so much for your help.