Search code examples
curljmeterhttprequestbackendless

testing a curl request with jmeter


I have a curl request and i don't know how to transform it in jmeter :

curl -H application-id:my-app-id \
     -H secret-key:my-secret-key \
     -H Content-Type:"multipart/form-data" \
     -H application-type:REST \
     --form upload=@/logo.jpg \
     -X POST \
     -v \
     http://localhost:8080/api/v1/files/Photos/logo.jpg

What is the best way of doing this?


Solution

  • Option 1: Record the request

    In JMeter:

    1. File -> Templates -> Recording -> Create
    2. Workbench -> HTTP(S) Test Script Recorder -> Start

    In console:

     curl -x localhost:8888 -H application-id:my-app-id ......
    

    Option 2: Building Request Manually

    1. Add HTTP Request sampler and configure it as follows:

      • Server Name: localhost
      • Port Number: 8080
      • Method: POST
      • Path: /api/v1/files/Photos/logo.jpg
      • Check Use multipart/form-data for POST
      • Switch to "Files Upload" tab
      • Click "Add" and provide full path to logo.jpg file, upload as Parameter Name and image.jpg as MIME Type
    2. Add HTTP Header Manager and provide your headers names and values there


    References:

    1. curl man page
    2. JMeter Proxy Step by Step
    3. How to Save ‘Loads’ of Time Using JMeter's Template Feature