我有一个curl请求,但我不知道如何在jmeter中转换它:
curl -H应用程序-id:my-app-id -H secret-key:my-secret-key -H Content-Type:"multipart/form-data“-H应用程序类型:REST --form upload=@/logo.jpg -X POST -v http://localhost:8080/api/v1/files/Photos/logo.jpg
做这件事的最好方法是什么?
发布于 2016-05-26 12:54:05
选项1:记录请求
在JMeter中:
测试脚本记录器Create
在控制台中:
curl -x localhost:8888 -H application-id:my-app-id ......选项2:手动构建请求
- 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
参考文献:
发布于 2016-05-25 23:17:14
很简单。
右键单击在Step1 --> Add-->ConfigElement-->HTTP Header Manager中创建的线程组,然后添加所有-H应用程序-id:my-app-id -H secret-key:my-secret-key -H Content-Type:"multipart/form-data“-H应用程序类型:REST注意:此处您不必附加-H
右键单击在Step1 --> Add--> Sampler -->HTTP Sampler中创建的ThreadGroup或IP = local host and post 8080和Path =/api/v1/ files /Photos/logo.jpg and method =post中创建的ServerName,并且有send files的add部分相应地添加
右键单击在Step1中创建的树--> Add-->Listener--> View result ThreadGroup
到最后,你的Jmeter脚本应该是这样的
TestPlan
ThreadGroup[threads =1 loopcount=1]
HTTP HeaderManager
HTTPSAmpler
View Result Tree测试愉快。要了解更多信息,请单击http://jmeter.apache.org/usermanual/component_reference.html。
发布于 2021-01-07 10:23:11
适用于JMeter 5.1或更高版本。有一个更简单的解决方案,用于从curl创建测试计划,就像在Postman中一样。
Tools Import from curl Create Test Plan→→Paste your curl→box
在一些旧版本中,路径可以是:
Help Import from curl Create Test Plan→→Paste your curl→box
https://stackoverflow.com/questions/37440639
复制相似问题