title: The specified HTTP method is not allowed for the requested resource
body: <p>I am using spring 4.1 and my  Rest Controller signature looks like:</p>
  
  <pre><code>@RestController
  @RequestMapping("/api/device")
  public class ApiRestController {
  
     public ResponseEntity&lt;Response&gt; singleResponse() {
          System.out.println("SDR GET");
          SingleDataResponse res = new SingleDataResponse();
          res.setCmd("8028");
          res.setData("xyz");
          res.setRfu("rfu");
          res.setSid("99");
          return new ResponseEntity&lt;Response&gt;(res, HttpStatus.OK);
      }
  
      @RequestMapping(value = "/single-res-post", method = RequestMethod.POST)
      @ResponseStatus(HttpStatus.CREATED)
      public ResponseEntity&lt;Response&gt; singleResponsePost(
              @RequestBody SingleDataRequest req, HttpServletRequest request,
              HttpServletResponse response) {
          System.out.println("SDR Post");
          SingleDataResponse res = new SingleDataResponse();
          res.setCmd(req.getCmd());
          res.setRfu(req.getRfu());
          res.setSid(req.getSid());
          res.setData("0");
          return new ResponseEntity&lt;Response&gt;(res, HttpStatus.OK);
      }
  
  }
  </code></pre>
  
  <p>I have added the below Bean in my WebMvcConfig</p>
  
  <pre><code>@Bean
  public RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
      RequestMappingHandlerAdapter adapter = new RequestMappingHandlerAdapter();
      adapter.setCacheSecondsForSessionAttributeHandlers(0);
      final MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter = new MappingJackson2HttpMessageConverter();
      List&lt;HttpMessageConverter&lt;?&gt;&gt; httpMessageConverter = new ArrayList&lt;HttpMessageConverter&lt;?&gt;&gt;();
      httpMessageConverter.add(mappingJacksonHttpMessageConverter);
  
      String[] supportedHttpMethods = { "POST", "GET", "HEAD" };
  
      adapter.setMessageConverters(httpMessageConverter);
      adapter.setSupportedMethods(supportedHttpMethods);
  
      return adapter;
  }
  </code></pre>
  
  <p>I am using HttpClient for Get and Post to access the above rest api</p>
  
  <p>I able to acess the Get Request but while sending the Post request I am getting the response</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/8.0.12 - Error report&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
     &lt;h1&gt;HTTP Status 405 - Request method 'POST' not supported&lt;/h1&gt;
     &lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;Request method 'POST' not supported&lt;/u&gt;&lt;/p&gt;
     &lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;The specified HTTP method is not allowed for the requested resource.&lt;/u&gt;&lt;/p&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Kindly suggest</p>
  
  <p>The code used to send the post request</p>
  
  <pre><code>public static void verifyIreoWSPost() throws Exception {
          String wms = "http://localhost:8080/test-rest/api/device/single-res-post";
          Map&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
          String json = "{\"sid\":\"99\",\"rfu\":\"rfu\",\"cmd\":\"8028\",\"data\":\"xyz\"}";
          headers.put(HttpHeaders.CONTENT_TYPE, "application/json");
          headers.put("username", "admin");
          headers.put("password", "admin");
          String response = HttpUtils.sendPost(wms, headers, json);
          System.out.println("post response: " + response);
      }
  </code></pre>