queryParam is giving junk value in scala

I am new to scala programming, when am trying to feed the CSV data to API request using queryparam giving me junk string. Please let me know am I doing anything wrong?

  • CSV Data :Number, Name 123,Foo 456,Bar
  • Scala function :def csvData(): ChainBuilder = { feed(csvFeeder) .exec(http(“Test”) .post(“//myURL_Without_IPAddress”) .queryParam(“number”,“${Number}”.toString) .queryParam(“name”,“${Name}”.toString)) }

URL constructed when I call the scenario :

http://myURL/&number=mypackagename%24%24Lambda%24345%2F0x0000000800f33398%4011a4d282&name=mypackagename%24%24Lambda%24348%2F0x0000000800f34b58%401facedda HTTP/1.1

Note: I tried to call queryParm which was mentioned in gatling.io website, but that is also not worked.

// with static values
http("Issues").get("https://github.com/gatling/gatling/issues")
  .queryParam("milestone", "1")
  .queryParam("state", "open")

// with Gatling EL strings
http("Issues").get("https://github.com/gatling/gatling/issues")
  .queryParam("milestone", "#{milestoneValue}")
  .queryParam("state", "#{stateValue}")

Honestly, the error is somewhere on your side.

You can check for yourself that queryParam works as expected:

There’s absolutely no way “queryParam(“number”,“${Number}”.toString) would generate the URL you mentioned. You can only generate this junk if instead of “${Number}” you’re passing a function but still calling toString on it, which does this: Object (Java Platform SE 8 )

Note: I tried to call queryParm which was mentioned in gatling.io website, but that is also not worked.

How does it not work? Are you sure you’re using Gatling 3.7 where the new #{} syntax was introduced?

@slandelle I am using Gatling 3.8.3 version.
The issue was when am sending the csv data in GET/POST request like below am able to see the CSV content in constructed URL, but when am trying to add the same through queryParm its giving me the above said Junk string.

.post(“/MyURL/test&number=${Number}&name=${name}”)
.get(“/MyURL/test&number=${Number}&name=${name}”)

Please provide a proper reproducer as described here, eg a project on GitHub anybody can then run, typically against a public website.

As is, there’s no way to figure out your issue from the fragments you provide.

Dont know queryParm is still not working. will share the entire project by uploading them to Github.
Meanwhile do we have a way to read the CSV file and assign it to some variables in scala class.
Lets say below is my csv file data.

Number, Name
123,Foo
456,Bar

In my scala class I have two variables name & number, using some for loop can I read the CSV file data and assign the values to the variables created in scala class?

Do you try Feeders ?

You must be more precise with questions and give example of code that not working.