0

I was writing JMeter tests for REST API. Its a post request and we need to send a big xml content in request body. So I was using CSV Data Set config to parameterize the xml content in body part.

I have created a CSV Data Set config for HTTP Request sampler.

In csv file, I am writing the whole xml content. 1 row for 1 request. It is working fine.

But I found this is bit complex as we have to maintain large lines of xml in csv file.

Is there any way we can write only xml file names or full paths in csv file and CSV DataSet config checks the name and then read the contents of that file and append in request body.

file-abc.xml
file-def.xml

I think this would be easy to maintain as we can have dedicated files for XML content.

Any way to do it using CSV DataSet config?

Or any other way to achieve the same in JMeter tests.

I found this question How to hold Xml file names in CSV Data set Config (Jmeter) I followed its answer but I am not able to pass the xml content in request body.

Its only passing xmlfile names written in csv file in the request body. But as per answer it reads the file from xml path/name and pass it in the parameter.

Kuldeep Singh
  • 1,214
  • 4
  • 18
  • 45

1 Answers1

1

You can keep the file names or paths to the files in the CSV file and read the file content using __FileToString() function directly in the HTTP Request sampler body

If you're keeping XML files in a separate folder you might find Directory Listing Config plugin easier to use in case you want to add/remove/rename files without having to maintain the CSV mapping.

Directory Listing Config plugin can be installed using JMeter Plugins Manager

enter image description here

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • Thanks for the answer. It was helpful. For anybody trying to get to the current jmx script directory here is the answer https://stackoverflow.com/a/27827110/446029 – Kuldeep Singh Sep 30 '19 at 10:49