jmeter json load-testing performance-testing rest

In Jmeter, What would be syntax of parameters in Body Data section of HTTP Request Sampler, if I am using Rest APIs and taking input from CSV files?

I am trying to create 10 users at the same time in Jmeter, using REST APIs.

Test Data i.e. input is taken from CSV files (The details of users like user name, last name , mobile)

For this I have added one thread group,User Defined Variable,HTTP Header Manager, HTTP Request Sampler (which perform successful login into web application), JSON PATH EXTRACTOR ( to extract auth token, which will be used while adding user)

To Add User, I have used one “Loop Controller” – “HTTP Request Sampler” – HTTP Header Manager, CSV Data Set Config.

And to track result, View Results Tree and Aggregate Report.

Please tell me what would be the syntax of parameters which I am passing in “Body Data” section of HTTP Request sampler, so that it can read values from csv files.

Below is the syntax I am using now to add single user.

"phoneNo": "9998885551",
"lastName": "john25",
"email": "[email protected]",
"firstName": "ricky25",
"mobileNo": "9820420420"

If your CSV file looks like:

9998885551,john25,[email protected],ricky25,9820420420
9998885552,john26,[email protected],ricky26,9820420421

Configuration should be the following:

  • Filename: full path to your source .csv file
  • Variable Names: phone,lastname,email,firstname,mobile
  • Delimiter: ,

Populate other values according to your test scenario i.e. whether you want test to stop on .csv file end or re-spin or whatever.

CSV Config

And your HTTP Request should look like:

Using CSV Variables in HTTP Request

The main point is that variables defined in the CSV Data Set Config need to match the ones in the HTTP Request.

See Using CSV DATA SET CONFIG guide for detailed instructions.

I would also recommend adding the following entry to your HTTP Header Manager:

  • Name: Content-Type
  • Value: application/json

elsewise your request will be treated like plain text and may fail.

Also don’t forget to disable View Results Tree listener for actual load test run as it consumes a lot of resources and may lead to out-of-memory errors on JMeter side.