title: Unable to send POST request in SpringMVC
body: <p>I have created an API using jersey and spring boot. Now when I hit POST request using Postman with following in request body:</p>
  
  <pre><code>{
       "name":"something", "email":"something","location":"something","dateOfBirth":"something"
  }
  </code></pre>
  
  <p>It works. Function to save this data is:</p>
  
  <pre><code>@POST
  @Path("/addEmployee")
      @Produces(MediaType.TEXT_PLAIN)
      public String addEmployee(@RequestBody Employee employee) {
          service.save(employee);
          return "Saved Successfully";
      }
  </code></pre>
  
  <p>Employee model is:</p>
  
  <pre><code>@Entity
  @Table(name = "employee")
  @XmlRootElement(name = "employee")
  @EntityListeners(AuditingEntityListener.class)
  public class Employee {
      public Employee() {
      }
      @Id
      @Column(nullable = false, name = "id")
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @Column(nullable = false, name = "name")
      private String name;
  
      @Column(nullable = false, name = "email")
      private String email;
  
      @Column(nullable = false, name = "location")
      private String location;
  
      @Column(nullable = false, name = "DOB")
      private String dateOfBirth;
  
      // getters and setters
  </code></pre>
  
  <p>This api is called by follwing function at client side:</p>
  
  <pre><code>@RequestMapping(value = "/addEmployee", method = RequestMethod.GET)
      public ModelAndView addEmployee(ModelAndView model) {
  
          RestTemplate restTemplate = new RestTemplate();
          String url = "http://localhost:8080/api/addEmployee";
  
          EmployeeInfo employee = new EmployeeInfo();
          employee.setName("Ashish");
          employee.setEmail("anyhing");
          employee.setDateOfBirth("mybirthday");
          employee.setLocation("home");
          ResponseEntity&lt;String&gt; response = restTemplate.postForEntity(url, employee, String.class);
  
          model.setViewName("homePage");
          return model;
      }
  </code></pre>
  
  <p>Employee info class is:</p>
  
  <pre><code>public class EmployeeInfo {
  
      private String name;
  
      private String email;
  
      private String location;
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public String getEmail() {
          return email;
      }
  </code></pre>
  
  <p>Error I'm getting is :</p>
  
  <pre><code>  2018-09-16 15:57:13.706 ERROR 14892 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.web.client.HttpClientErrorException: 404 null] with root cause
  
  org.springframework.web.client.HttpClientErrorException: 404 null
      at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:86) ~[spring-web-4.3.19.RELEASE.jar:4.3.19.RELEASE]
      at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:708) ~[spring-web-4.3.19.RELEASE.jar:4.3.19.RELEASE]
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:661) ~[spring-web-4.3.19.RELEASE.jar:4.3.19.RELEASE]
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:621) ~[spring-web-4.3.19.RELEASE.jar:4.3.19.RELEASE]
      at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:415) ~[spring-web-4.3.19.RELEASE.jar:4.3.19.RELEASE]
      at com.example.controller.Home.addEmployee(Home.java:82) ~[classes/:na]
  </code></pre>
  
  <p>and a long list like this.</p>
  
  <p>Form which calls this is:</p>
  
  <pre><code>&lt;form name="myform" method="post" action="addEmployee" &gt;
          &lt;input type="submit" value="Save"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>EDIT: On changing client side's  method = RequestMethod.GET to RequestMethod.POST, nothing happens, still getting same erro
  What I'm doing wrong?</p>