下面来看使用Jmeter怎么来做HTTP的接口请求,在请求中使用浏览器的network获取请求的信息,见获取到的请求信息:
General:
Request URL:http://180.97.80.42:9X90/v4/login
Request Method:POST
Status Code:200 OK
Remote Address:180.97.80.42:9X90
ResponseHeaders:
Access-Control-Allow-Headers:Origin,Content-Type,Accept,Parkingwang-Client-Source,Accept-Version
Access-Control-Allow-Origin:http://180.97.80.42:9X97
Connection:keep-alive
Content-Encoding:gzip
Content-Type:application/json; charset=UTF-8
Date:Wed, 02 May 2018 09:49:45 GMT
Server:nginx/1.10.1
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:PHP/5.6.30
RequestHeaders:
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate
Accept-Language:zh-CN,zh;q=0.8
Accept-Version:v3.0
Connection:keep-alive
Content-Length:93
Content-Type:application/json;charset=UTF-8
DNT:1
Host:180.97.80.42:9090
Origin:http://180.97.80.42:9X97
Parkingwang-Client-Source:ParkingWangAPIClientWeb
Referer:http://180.97.80.42:9097/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
RequestPayload
在如上的信息中,可以得出请求如下的结论:
请求方法:POST
请求URL:
http://180.97.80.42:9X90/v4/login
请求参数:
{"username":"","password":""}
请求Headres为:
Content-Type:application/json;charset=UTF-8
Parkingwang-Client-Source:ParkingWangAPIClientWeb
确定如上信息后,在Jmeter中再次创建一个新的线程组,以及创建新的HTTP请求,见HTTP信息头管理器:
见HTTP请求的接口信息:
点击执行后,可看到执行的结果,见执行结果的截图: