Reputation: 185
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?
Upvotes: 13
Views: 23508
Reputation: 1632
For JMeter 5.1 or higher. There is an easier solution for creating test plan from curl just like in Postman
Tools
→ Import from curl
→ Paste your curl into the box → Create Test Plan
In some older version, the path can be:
Help
→ Import from curl
→ Paste your curl into the box → Create Test Plan
Upvotes: 9
Reputation: 168092
Option 1: Record the request
In JMeter:
In console:
curl -x localhost:8888 -H application-id:my-app-id ......
Option 2: Building Request Manually
Add HTTP Request sampler and configure it as follows:
localhost
8080
POST
/api/v1/files/Photos/logo.jpg
Use multipart/form-data
for POSTupload
as Parameter Name and image.jpg
as MIME TypeAdd HTTP Header Manager and provide your headers names and values there
References:
Upvotes: 8
Reputation: 477
Simple .
RightClick on TestPlan --> Threads-->Thread Group
Add a HTTP Header manager add all Header entries
Right Click on Thread Group Created in Step1 --> Add-->ConfigElement-->HTTP Header Manager and add all[ -H application-id:my-app-id -H secret-key:my-secret-key -H Content-Type:"multipart/form-data" -H application-type:REST] Note: here you dont have to append -H
Add a HTTP sampler
Right Click on the ThreadGroup Created in Step1 --> Add-->Sampler-->HTTP Sampler provide ServerName or IP = local host and Port= 8080 and in Path =/api/v1/files/Photos/logo.jpg and method = post and There is add section for send files add accordingly
Add a Listener to verify the requests
Right Click on ThreadGroup created in Step1 --> Add-->Listener--> View result tree
By the end your Jmeter script should like
TestPlan
ThreadGroup[threads =1 loopcount=1]
HTTP HeaderManager
HTTPSAmpler
View Result Tree
Happy Testing . for more information http://jmeter.apache.org/usermanual/component_reference.html if it helps dont forget to click answered.
Upvotes: 3