Lucian Irimie
Lucian Irimie

Reputation: 812

how to send a file as a request as a raw http request body

I have working http request call with JSON body. WHat I want to do is to use the same content as an external file. For this I have used "send files with the request" function, without using multi-part because our server doesn't support that. I tried with or without parameter name or MIME type and the result is the same 400. The same call is working if instead I use the JSON in the body. File location is good, i double checked that. THe actual content of the file is not displayed in the request.

Any ideas?

Upvotes: 3

Views: 4944

Answers (2)

Shai Alon
Shai Alon

Reputation: 990

You can use the Jmeter function __fileToString for that: https://jmeter.apache.org/usermanual/functions.html#__FileToString

Upvotes: 0

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34556

As per documentation:

Name of the file to send. If left blank, JMeter does not send a file, if filled in, JMeter automatically sends the request as a multipart form request. 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. This allows arbitrary bodies to be sent. This functionality is present for POST requests after version 2.2, and also for PUT requests after version 2.3. See below for some further information on parameter handling.

Upvotes: 1

Related Questions