天天看點

Jmeter4.0接口測試之HTTP的請求(五)

下面來看使用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資訊頭管理器:

Jmeter4.0接口測試之HTTP的請求(五)

見HTTP請求的接口資訊:

Jmeter4.0接口測試之HTTP的請求(五)

點選執行後,可看到執行的結果,見執行結果的截圖:

Jmeter4.0接口測試之HTTP的請求(五)