title: Spring RestTemplate Post getting 500 internal server error
body: <p>Hi I'm new to Spring framework.I have written app which post object to RESTAPI using Resttemplate but i am getting this error</p>
  
  <pre class="lang-none prettyprint-override"><code>23:07:05.856 [main] DEBUG o.s.web.client.RestTemplate - Created POST request for
    "http://dummyurl.net/Index"    
  23:07:05.887 [main] DEBUG o.s.web.client.RestTemplate - Setting request Accept
    header to [application/json, application/*+json]
  23:07:05.887 [main] DEBUG o.s.web.client.RestTemplate - Writing
    [org.hrishi.ConsumeReStApi.Info@727803de] as "application/json" using
    [org.springframework.http.converter.json.MappingJacksonHttpMessageConverter@704921a5]
  23:07:05.981 [main] WARN  o.s.web.client.RestTemplate - POST request for "dummyurl.net"
   resulted in 500 (Internal Server Error); invoking error handler
  Exception in thread "main" org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error
      at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:94)
      at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:598)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:556)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:512)
      at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:363)
      at org.hrishi.ConsumeReStApi.App.main(App.java:35)
  </code></pre>
  
  <p><strong>and this my code</strong></p>
  
  <pre><code>        String url=    "http://dummyurl.net/Index";    
          RestTemplate restTemplate = new RestTemplate();
          MultiValueMap&lt;String, String&gt; headers = new LinkedMultiValueMap&lt;String, String&gt;();
          headers.add("Content-Type", "application/json");
          Info info1=new Info();
          info1.Id="1711";
          info1.Name="Hrishi";
          HttpEntity&lt;Info&gt; HReq=new HttpEntity&lt;Info&gt;(info1,headers);
          ResponseEntity&lt;Info&gt; info = restTemplate.postForEntity(url, HReq, Info.class);
          System.out.print("id : "+info.getBody());
  </code></pre>
  
  <p><strong>and this is request object</strong></p>
  
  <pre><code>public class Info {
  
      public String Id;
      public String Name;
  
      public String getName() {
          return Name;
      }
  
      public String getId() {
          return Id;
      }
  
  }
  </code></pre>