user1532146
user1532146

Reputation: 303

How can I send file using parameter instead set it in FilePath in JMeter HTTP Request Sampler?

When I use bean shell script to preload the file to a variable and then set it in parameter of HTTP request sampler to upload file, from the wireshark packets I find that the content-length is not right. Also the content-type is set to text/plain which cause problem. How can I change it?

Below are some pictures to show the jemter setup and wireshrak snoops.

The wireshark snoop when the content of the file set as the value of the parameter of the Http request sampler The jmeter test element setup showing that the the content of the file is set in the http request parameter

Upvotes: 1

Views: 9343

Answers (1)

Dmitri T
Dmitri T

Reputation: 168042

You're using wrong configuration:

  1. Check Use multipart/form-data for POST box
  2. Remove your file from Parameters area
  3. Add it to Send Files With the Request area like:

    • File Path: ${__property(FileData,,)}
    • Parameter Name: File
    • MIME Type: text/plain

      Example upload configuration

See Performance testing: Upload and Download Scenarios with Apache JMeter guide for more information on simulating file upload and download events in your JMeter script.

Upvotes: 2

Related Questions