Search code examples
curljmeterjmeter-plugins

Analog to curl's --data-binary switch in jmeter's HTTP Request


I've got a working curl request that goes as so:

curl -H "Content-Type: application/octet-stream" -X POST --data-binary @sample.bin http://127.0.0.1:31415/test

sample.bin holds binary data.

In my jmeter test plan, I have "sample.bin" stored in FILENAME. This is what I put into the body of my HTTP Request:

${__eval( ${__FileToString(${FILENAME})})}

Unsurprisingly, this isn't working out. How can I emulate the --data-binary switch?


Solution

  • Alright, after RTFM carefully yet another time, I discovered that if it is a POST or PUT or PATCH request and there is a single file whose 'Parameter name' attribute (below) is omitted, then the file is sent as the entire body of the request, i.e. no wrappers are added.

    Thus, putting ${FILENAME} under file path in the "Send Files with the request" section (while leaving its paramter name empty and specifying an encoding) did the trick for me:

    enter image description here