I'm trying to send a csv file as a request in body.
It's working fine for me in Postman. But I'm getting the below error in Jmeter.
{
"id":32,
"deleted":null,
"uuid":"f5cec747-4794-4e54-9c4b-58da61f30921",
"status":"Error",
"csvFileName":"",
"unsuccessfulRecords":[
"['Not Applicable', '{\\'csvFile\\': [ErrorDetail(string=\\'The submitted data was not a file. Check the encoding type on the form.\\', code=\\'invalid\\')], \\'assets\\': [ErrorDetail(string=\\'Expected a list of items but got type \"str\".\\', code=\\'not_a_list\\')]}']"
],
"successfulRecordsCount":0,
"duplicateRecordsCount":0,
"createdBy":"user",
"createdAt":"2022-12-06T09:58:51.285524Z",
"modifiedAt":"2022-12-06T09:58:51.285538Z",
"idAllowdAt":"2022-12-06T09:58:51.285538Z",
"idAllowListType":1
}
Below is the request i'm sending as part of Body Data. The REST Api accept these parameters, and afer that it imports the CSV file:
{
"csvFile": "${__FileToString(D:/Users/anabeel/Downloads/Demo/Demo.csv,,)}",
"allowlistTypeId": "1",
"createdBy": "user",
"assets": "['asset1', 'asset2']",
"uuid": "${requestIndex}",
"tags": "{'Platform Family':[{'abc123':'LinuxOS System'}]}",
"tenantId": "abc456"
}
Content-type: application/json
It seems I'm not importing the csv file the right way. Can someone please help me as I dont have much experience working with Jmeter. I also tried using CSV Data Set Config, but it didn't worked for me.
CodePudding user response:
If your request "working fine for me in Postman" you can just record it using JMeter's
Copy your CSV file to bin folder of your JMeter installation
Run your request in Postman
JMeter will generate proper HTTP Request sampler and HTTP Header Manager
Parameterize the path to the CSV file if needed
Your JMeter request should be working fine now
More information: JMeter Performance Testing: Upload and Download Scenarios