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.

1
  • please show us screenshot of your Http request in jmeter Commented Oct 15, 2017 at 8:56

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.