3
votes

All, Every HTTP Request I make to my test REST Service is sent with the method set to GET. Tomcat rejects with a 405 - Unsupported Method. Doesn't matter what I change it to (POST, PUT, etc) Jmeter always sends a GET.

I set up the simplest possible test case by creating a Threadgroup with an HTTP Request Sampler and a View Results Tree. I send a JSON body to the REST Services which just echos back the request along with an ID. Works great with Google's REST Client UI.

Here is the result from the View Results Tree:

Response code: 405
Response message: Method Not Allowed

Response headers:
HTTP/1.1 405 Method Not Allowed
Server: Apache-Coyote/1.1
Allow: POST
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1045
Date: Fri, 18 Jul 2014 21:39:27 GMT

Here is the RequestMapping from my REST Service

@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")

Here are some screenshots from my results. I wonder why there are two URI's below the HTTP Request in the tree? Notice the POST request looks correct. GET Request

POST Request

Test PlanHeader Manager

4

4 Answers

5
votes

Since the right answer is not provided yet: It's the "Follow Redirects" Option that causes this behavoir under certain circumstances. see http://www.sqaforums.com/showflat.php?Cat=0&Number=687068&Main=675937

1
votes

Try to end the 'Path' value of HTTP Request with '/'. It has to remove the GET result in View Results Tree.

0
votes

Content-Type should be application/json. It can not be text/html.

Set that in HTTP Header Manager. I assume you have set authentication details correctly.

0
votes

We need to have three things properly set.

  1. Content type which will be application/json
  2. set the endpoint correctly in the path ,which you can see in soup ui
  3. Check the port number on which the api wil get run on [All this u can first check on soupui and then try running the same in jmeter