1. 程式人生 > >jmeter中http請求出現415解決方案

jmeter中http請求出現415解決方案

jmeter中http請求出現415解決方案

 

做介面測試發現postman請求介面返回正常,但是jmeter出現415請求不通:The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.

在檢視結果樹中看到:

Request Headers:
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 27
User-Agent: Jakarta Commons-HttpClient/3.1

 

這裡的Content-Type: application/x-www-form-urlencoded 方式是Jquery的Ajax請求預設方式,這有可能導致向伺服器傳送資料不成功;因為http服務傳送的post請求認是json資料格式所以資料接收不到;

在HTTP資訊頭管理器將Content-Type修改為:application/json告訴伺服器請求的主題內容是json格式的字串,伺服器端會對json字串進行解析;