Nathan Weddle
Nathan Weddle

Reputation: 197

JMeter HTTP Request: Always Sending GET Method

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 Plan Header Manager

Upvotes: 6

Views: 7607

Answers (5)

Cristofer
Cristofer

Reputation: 1106

I had the same problem. I tried everything also I read this question and all answers before find the thing that worked for me.

Select Redirect Automatically

Upvotes: 2

vijay Ingale
vijay Ingale

Reputation: 3

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

Upvotes: 0

Nico
Nico

Reputation: 81

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

Upvotes: 7

Vadim Shpakovsky
Vadim Shpakovsky

Reputation: 31

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

Upvotes: 2

vins
vins

Reputation: 15370

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.

Upvotes: 0

Related Questions