Fetching Int variable from terminal and passing it to another method(retaining data type Int)


I am new to Gatling and don’t have any experience working on Scala as well.
i am writing a performance script which takes a parameter(Id of type Int) from terminal and it is read by the object class which passes it to the Payload class.
This is what I have written so far:

Class 1: (Object class)


var Ids = System.getProperty(“Ids”).toInt //reading it from terminal

session.set(“no_of_ids”, Ids) //storing it in session




http(“abc”) // For making http calls. Name provided here will be used in test results

.post("/v1") // provide your end point to which http post call is to be made.

.body(StringBody(Payloads.Query("""${no_of_ids}"""))) //passing it to the payload class, here its being passed as string instead of Int

.check( bodyString.saveAs( “RESPONSE” ) )

.check(status.is(200)) // It checks that the HTTP response has a 200 status

.check(responseTimeInMillis.saveAs(“execLatency”)) // captures the response time of this request in milliseconds and saves it in session as execLatency


In the payloads class, I have the following:

Class 2:(Payload class)

def Query(no_of_ids: Int) =

“”"{“query”: “{\n company {\n Ids(first:”${no_of_ids}") {\n edges {\n node {\n id\n displayName\n …"""

But it throws the error “type mismatch; found : String(”${no_of_ids}") required: Int"

If I change the data type of ‘no_of_ids’ in class 2 to String, it does not throw the error. Somehow, the variable being passed is of type String and not integer(which is want I actually want), even though I am converting it to Int.

Can someone please help as to what am I doing wrong while passing the variable.

Or if it can be done in a different way?