Jmeter_ Response Error Like:http响应代码:405不允许使用方法

时间:2016-06-28 10:29:52

标签: jmeter

当我尝试使用Jmeter使用HTTP的POST方法在Web应用程序中上传图像时,其抛出错误如下

采样器请求:

Size in bytes: 436
Headers size in bytes: 335
Body size in bytes: 101
Sample Count: 1
Error Count: 1
Data type ("text"|"bin"|""): text
Response code: 405
Response message: Method Not Allowed

Response headers:
HTTP/1.1 405 Method Not Allowed
Allow: GET, HEAD, OPTIONS, TRACE
Content-Length: 101
Content-Type: text/html
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET
Set-Cookie: ARRAffinity=a1634f39ccba9517317254d32be7078bb62c2877a947d85cab990f2708382045;Path=/;Domain=revflexsit.azurewebsites.net
Date: Tue, 28 Jun 2016 10:04:41 GMT


HTTPSampleResult fields:
ContentType: text/html
DataEncoding: null

请求

POST http://revflexsit.azurewebsites.net/#//testerprofile

POST data:
--8WPDqrXY5glD81_9CcLHn-xfOTrWvH4Dh4srjx
Content-Disposition: form-data; name="profileUploadPhoto"; filename="Tulips.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binary

<actual file content, not shown here>
--8WPDqrXY5glD81_9CcLHn-xfOTrWvH4Dh4srjx--


[no cookies]

Request Headers:
Connection: keep-alive
Content-Length: 621121
Content-Type: multipart/form-data; boundary=8WPDqrXY5glD81_9CcLHn-xfOTrWvH4Dh4srjx; charset=US-ASCII
Host: revflexsit.azurewebsites.net
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_40)

响应数据:

The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

1 个答案:

答案 0 :(得分:2)

服务器响应几乎是不言自明的,您不能向该URL发出POST请求,只允许GET,HEAD,OPTION和TRACE。

为什么不使用HTTP(S) Test Script Recorder记录测试场景并根据需要修改生成的测试“骨架”?

如果您仍然渴望手动构建方案,查看http://revflexsit.azurewebsites.net/网站,似乎正确的请求将如下所示:

  • 路径:/api/TesterProfile/UploadTesterProfile?Id=${YOUR_ID_HERE}&UpdateAdminId=0&dimensions=x,y,x,y
  • 文件上传:

    • 文件路径:图片的完整路径,您正在尝试上传
    • 参数名称:profileUploadPhoto
    • MIME类型:相关照片MIME Type

不要忘记勾选“使用多部分/表单数据进行POST”框。

有关详细说明,请参阅How to Test Image Upload Functionality With JMeter