I need to test an API that accepts bulk JSON requests using records from a CSV file. I'm well versed in sending simple REST requests using data from CSV files (and therefore JMeter variables and all that).
Is it possible for JMeter to batch a CSV file of 10,000 records into JSON payloads of 100 records each?
I've found answers that cover making JSON payloads from CSV files line-by-line, and even how to use pre-made JSON files as payloads, but nothing about dynamically creating JSON payloads from multiple lines in a CSV file before sending the requests.
For example:
The CSV would be something like
col1,col2
a,b
c,d
e,f
...
And I need a JSON payload like
{
'Some keys that dont change': null,
[
{'RecordNum': 1, 'col1': 'a', 'col2': 'b'},
{'RecordNum': 2, 'col1': 'c', 'col2': 'd'},
{'RecordNum': 3, 'col1': 'e', 'col2': 'f'},
...
]
}
TIA!
Reading multiple lines from CSV is not possible with CSV Data Set Config
. So you have to rely on JSR223_PreProcessor
.
You can read the CSV file and do the required payload manipulation. Of course, you need to know groovy for that. Not so elegant solution that I can think of:
Output:-
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.