Saturday 21 July 2018

HTTP Request to send multiple text Files using ${__FileToString()}

While working on Jmeter, we often came across situations where multiple files have to be sent to server as an attachment with the HTTP request.

In case, where a single file to be sent to server, below function works fine.

${__FileToString(C:\Users\user\Downloads\data.csv,,)}

However, in case of multiple files, one needs to work in the below manner.

Create a csv with all the file names. See below


Add a CSV Data Set config

The final HTTP request would look like


${__FileToString(C:\Users\XXX\Desktop\Final_Scripts\\${__V(filename)}.txt,,)}

Some people claim that ${__eval()} works with multiple/dynamic files. However, this did not worked for me. Hence, I used ${__V()}.

Don't forget to use double slash(\\) before the ${__V()} function.