title: Spring framework HttpMessageNotReadableException: Required request body is missing
body: <p>I'm trying to make a post request in React to a backend server in <code>Spring</code>, but keep getting the error bellow: </p>
  
  <blockquote>
    <p>[ERROR] -
    org.springframework.http.converter.HttpMessageNotReadableException:
    Required request body is missing.</p>
  </blockquote>
  
  <p>It works fine on postman.</p>
  
  <p>Code from the react part:</p>
  
  <pre><code>let testeDTO = JSON.stringify({
    email: "teste@@teste.com",
    senha: "1234",
    grupo: 1
  });
  
  axios
    .post("http://192.168.0.49:8080/site/login/", testeDTO, {
      headers: {
        "Content-Type": "application/json"
      }
    })
    .then(response =&gt; {
      console.log(response);
    })
    .catch(erro =&gt; {
      console.log(erro.response);
    });
  </code></pre>
  
  <p>Annotations on the rest controller:</p>
  
  <pre><code>@RestController
  @RequestMapping("/site/login")
  </code></pre>
  
  <p>Code from Spring:</p>
  
  <pre><code>@PostMapping
  public testeDTO login(@RequestBody TesteDTO testeDTO) {
  
  }
  </code></pre>
  
  <p>CORS class:</p>
  
  <pre><code>@WebFilter(urlPatterns = {"/*"})
  public class CORSFilter implements Filter {
  
      @Override
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
          HttpServletRequest request = (HttpServletRequest) servletRequest;
          HttpServletResponse response = (HttpServletResponse) servletResponse;
          response.setHeader("Access-Control-Allow-Origin", "*");
          response.setHeader("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE, OPTIONS");
          response.setHeader("Access-Control-Allow-Headers", "*, Content-Type, authorization, grupo, usuario");
          filterChain.doFilter(request, response);
      }
  }
  </code></pre>
  
  <p>DTO code:</p>
  
  <pre><code>public class TesteDTO {
  
      private String email;
      private String senha;
      private Long grupo;
  
      //getters and setters
  }
  </code></pre>