Saša
Saša

Reputation: 4798

Configure jMeter Http Request to emulate this curl command

I have a problem with preparing HTTP Requers in jMeter from the curl command I have:

curl --insecure -X POST -H "Content-Type:multipart/form-data" --header 
'header-param-1: aGVhZGVyLXBhcmFtLTE=' --header 'header-param-2: aGVhZGVyLXBhcmFtLTI=' 
--header 'header-param-3: aGVhZGVyLXBhcmFtLTM=' -F "file=@C:\temp\file to upload.zip" 
--form "metadata={\"jsonParam1\": \"text1\", \"jsonParam2\": 999, \"jsonParam3\": 10222, 
\"jsonParam4\":  \"2017-10-13T23:23:02.677Z\", \"jsonParam5\": \"text5\", 
\"jsonParam6\": \"3\", \"fileName\": \"file to upload.zip\", 
\"fileType\": \"application/pdf\"};type=application/json" 
"http://localhost:7001/context/rest/v1/uploadservice"

Basically, it is sending a file as multipart/form-data and json in the body as application/json type. The curl command is working as expected, but I couldn't make jMeter do the same.

I tried to find proper solution and ended up with a promise that manually constructing body data would help, but I had no luck with it.

I am using Cygwin for curl, since I use Windows. I also tried to use postman, but also failed to configure it.

Please help.

Upvotes: 1

Views: 2193

Answers (2)

Dmitri T
Dmitri T

Reputation: 168092

Just record the request.

  1. Copy file to upload.zip to "bin" folder of your JMeter installation
  2. From JMeter's main menu choose `File -> Templates -> Recording" and click "Create"
  3. Expand WorkBench -> HTTP(S) Test Script Recorder and click "Start"
  4. Run your "curl" command like:

    curl -x http://localhost:8888 --insecure -X POST -H ......
    
  5. JMeter will capture your request and store it under Test Plan -> Thread Group -> Recording Controller

References:

Upvotes: 1

UBIK LOAD PACK
UBIK LOAD PACK

Reputation: 34536

Create an HTTP Request with Header Manager as child Test Plan

enter image description hereWhere Header Manager is:

Where HTTP Request "Parameters" panel is configured like this:

Http Request parameters

And "Files Upload" panel in it:

enter image description here

Upvotes: 1

Related Questions