title: Error 400 Spring Json @RequestBody when doing post
body: <p>Here are the classes involve.</p>
  
  <pre><code>public class UserAuthDto {
  
      private String username;
  
      private String password;
  
      private List&lt;String&gt; roles;
  
      private String tenantCode;
  
      public UserAuthDto(String username,
                             String password,
                             List&lt;String&gt; roles,
                             String tenantCode){
          this.username=username;
          this.password=password;
          this.roles=roles;
          this.tenantCode=tenantCode;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public void setRoles(List&lt;String&gt; roles) {
          this.roles = roles;
      }
  
      public void setTenantCode(String tenantCode) {
          this.tenantCode = tenantCode;
      }
  
      public String getUsername() {
          return username;
      }
  
      public String getPassword() {
          return password;
      }
  
      public List&lt;String&gt; getRoles() {
          return roles;
      }
  
      public String getTenantCode() {
          return tenantCode;
      }
  }
  </code></pre>
  
  <p>Another DTO </p>
  
  <pre><code>public class UserAuthRequest {
  
      private UserAuthDto userAuthDto;
  
      public UserAuthRequest(UserAuthDto authDto){
          if(authDto == null){
              throw new IllegalArgumentException("User Authentication DTO Should Not be null");
          }
          this.userAuthDto = authDto;
      }
      public String getUsername(){
          return userAuthDto.getUsername();
      }
  
      public String getPassword(){
          return userAuthDto.getPassword();
      }
  
      public List&lt;String&gt; getRoles(){
          return  userAuthDto.getRoles();
      }
  
      public String getTenantCode(){
          return  userAuthDto.getTenantCode();
      }
  
      public void setUsername(String username) {
          this.userAuthDto.setUsername(username);
      }
  
      public void setPassword(String password) {
          this.userAuthDto.setPassword(password);
      }
  
      public void setRoles(List&lt;String&gt; roles) {
          this.userAuthDto.setRoles(roles);
      }
  
      public void setTenantCode(String tenantCode) {
          this.userAuthDto.setTenantCode(tenantCode);
      }
  }
  </code></pre>
  
  <p>And here's the Controller that was processing the request.</p>
  
  <pre><code>@RequestMapping(value = "authenticate", method = RequestMethod.POST,consumes = "application/json",produces = "application/json")
      public UserAuthResponse authenticate(@RequestBody UserAuthRequest authRequest){
         //.
      }
  </code></pre>
  
  <p>However when I send this data</p>
  
  <pre><code>{"username": "test","password":"test","roles":null,"tenantCode":"test"}
  </code></pre>
  
  <p>I receive a 400 bad request. any idea why?</p>