How to use curl request in JMeter?

末鹿安然 提交于 2019-12-12 02:27:35

问题


I have such curl command:

curl -X POST -T "{sample_data.csv}" -H "Content-Type: text/csv" https://api.mysite.com/v1/jobs/upload.json?key={api_key}

The problem is I don't understand in which component in JMeter I should pass "{sample_data.csv}" file to upload to the endpoint.

Now I have such configuration:

When I run test it shows me:

"error":{"message":"Un-Acceptable format, Content-Type must be one of those listed in \"formats\" but you sent \"multipart/form-data; boundary=E-VEr1-ZesF7xja5HezBWptB6xP_gsGODn\"","formats":["text/csv","text/plain","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/xml","application/vnd.oasis.opendocument.spreadsheet"]}}

回答1:


  1. Change "Protocol" to https
  2. Uncheck "Use multipart/form-data for POST"
  3. In "Send Files With the Request" click "Add" and provide file location
  4. Add HTTP Header Manager to sent "Content-Type" header with the value of "text/csv"



回答2:


To simulate this curl call with JMeter you'll need:

HTTP Request Sampler configured as follows:

  • Server Name or IP: anarinsky.aaa.com
  • Protocol: http
  • Method: POST
  • Path: /rest/secure/requestOrderMultipleAttr/skuOrderList/AAA_Prod_Go_d2/quantityAdult/1/quantityChild/1/email/anarinsky@aaa.com
  • Parameters: Name: email Value: anarinsky@aaa.com

HTTP Authorization Manager as a child of HTTP Request (if you want to use username/password only for this HTTP Request) or at the same level if you intend to use it for all requests in scope.

  • Username: anarinsky@aaa.com
  • Password: a1234

Adapt your own parameters to this example .



来源:https://stackoverflow.com/questions/32970805/how-to-use-curl-request-in-jmeter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!