1

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.

Saša
  • 4,416
  • 1
  • 27
  • 41

2 Answers2

1

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

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • I already tried that, but it doesn't work. I am afraid I need to do it manually through "Body Data". I am struggling with that approach now. – Saša Oct 16 '17 at 08:30
1

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:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133