title: Resttemplate and patch, invalid
body: <p>I use spring 1.4.3</p>
  
  <p>I try to call a web service</p>
  
  <pre><code>  @PatchMapping(value = "/members/{memberId}/card")
    public ResponseEntity updateMemberCardId(@PathVariable("memberId") Long memberId, @RequestBody String cardId) throws ResourceNotFoundException {
          memberService.updateMemberCardId(cardId, memberId);
          return new ResponseEntity&lt;&gt;(HttpStatus.NO_CONTENT);
    }
  </code></pre>
  
  <p>In my application, </p>
  
  <pre><code>@Component
  @Configuration
  public class ClientRestConfig {
  
      @Bean
      public RestTemplate restTemplate(RestTemplateBuilder builder, @Value("${main.server.url}") String mainServerUrl, @Value("${commerce.username}") String commerceUsername, @Value("${commerce.password}") String commercePassword,  @Value("${connection.timeout}") int timeout) {
          return builder.setConnectTimeout(timeout).setReadTimeout(timeout).basicAuthorization(commerceUsername, commercePassword).rootUri(mainServerUrl).build();
      }
  
  }
  </code></pre>
  
  <p>In another method I do</p>
  
  <pre><code>String cardId = "123456789";
  
  HttpHeaders headers = new HttpHeaders();
  headers.setContentType(MediaType.APPLICATION_JSON);
  HttpEntity&lt;String&gt; entity = new HttpEntity&lt;&gt;(cardId, headers);
  
  ResponseEntity responseEntity =  restTemplate.patchForObject("/rest/members/1/card", entity, ResponseEntity.class);
  </code></pre>
  
  <p>I get this error</p>
  
  <blockquote>
    <p>java.net.ProtocolException: Invalid HTTP method: PATCH    at
    java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:440)
    ~[na:1.8.0_111]   at
    sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:552)
    ~[na:1.8.0_111]</p>
  </blockquote>