I have a Csv file with multiple records(comma Seperated), i need a groovy script that can fetch all the data's from csv and make a json array and send a POST request in jmeter. Here is my code below. But it only fetches one record
import groovy.json.*
import groovy.json.JsonBuilder
def jsonBuilder = new groovy.json.JsonBuilder()
jsonBuilder {
id Integer.parseInt(vars.get("id"))
name vars.get("first_name")
last_name vars.get("last_name")
email vars.get("email")
institute_id Integer.parseInt(vars.get("institute_id"))
category_id Integer.parseInt(vars.get("category_id"))
value Boolean.parseBoolean(vars.get("value"))
}
sampler.addNonEncodedArgument("",jsonBuilder.toPrettyString(),"")
sampler.setPostBodyRaw(true)
vars
is? – Gergely Toth{ "_token": "sometokentext", "candidate": [{ "id": 1, "first_name": "${first_name}", "last_name": "${last_name}", "email": "${email}", "institute_id": ${institute_id}, "category_id": ${category_id}, "value": ${value} }], "test_id": "${id}", "selectedDate": "${date}" }
– Kiril S.