title: How can i get params in spring from curl -X request?
body: <p>I have a problem with processing params from curl request to my spring-boot app.</p>
  
  <p>My controller post method:</p>
  
  <pre><code>@RequestMapping(value = "/cat", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
  public ResponseEntity addCat(@Valid @ModelAttribute NewCatRequest newCatRequest, BindingResult bindingResult) {
      System.out.println( newCatRequest);
      if (bindingResult.hasErrors()) {
          return ResponseEntity.badRequest().body(bindingResult.getFieldError().getDefaultMessage());
      }
  
      int rowsAffected = catsRepository.saveCat(newCatRequest.getName(), newCatRequest.getColor(), newCatRequest.getTail_length(), newCatRequest.getWhiskers_length());
      if (rowsAffected == 1) {
          return ResponseEntity.ok().body(newCatRequest);
      } else {
          return ResponseEntity.badRequest().body("There was an unexpected error while trying to create cat for you :(");
      }
  }
  </code></pre>
  
  <p>And the problem is: when i'm trying to send this with curl:</p>
  
  <blockquote>
    <p>curl -X POST <a href="http://localhost:8080/cat" rel="nofollow noreferrer">http://localhost:8080/cat</a> \
    -d "{\"name\": \"Tihon\", \"color\": \"red &amp; white\", \"tail_length\": 15, \"whiskers_length\": 12}"</p>
  </blockquote>
  
  <p>I have all null params in 'newCatRequest':
  NewCatRequest{name='null', color='null', tail_length=0, whiskers_length=0}</p>
  
  <p>BUT when i'm trying to do the same with Postman (POST method, x-www-form-urlencoded in body with my params) i have a valid result:
  <a href="https://i.stack.imgur.com/89shl.png" rel="nofollow noreferrer">Result from Postman</a></p>
  
  <p>Help me pls to understand what's the problem.</p>