title: Spring RestController POST 400 Bad Request
body: <p>I have a Spring RestController that any attempt to post to it returns 400 Bad Request despite seeing the correct data being sent in Chrome Developer Tools. The @Valid annotation is kicking it out because the ParameterDTO object is not being populated at all.</p>
  
  <p>My Controller</p>
  
  <pre><code>@RestController
  @RequestMapping(path = "/api/parameters", consumes = {MediaType.APPLICATION_JSON_VALUE}, produces = {MediaType.APPLICATION_JSON_VALUE})
  public class ParameterResource {
  
      private final ParameterService parameterService;
  
      @Autowired
      public ParameterResource(ParameterService parameterService) {
          this.parameterService = parameterService;
      }
  
      @GetMapping
      public ResponseEntity&lt;?&gt; getParameters(@RequestParam(value = "subGroupId", required = false) Integer subGroupId) {
          if (subGroupId != null) {
              return ResponseEntity.ok(parameterService.getParameters(subGroupId));
          }
          return ResponseEntity.ok(parameterService.getParameters());
      }
  
      @PostMapping
      public ResponseEntity&lt;?&gt; createParameter(@Valid ParameterDTO parameterData) {
          int id = parameterService.saveParameter(parameterData);
          URI uri = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
                  .buildAndExpand(id).toUri();
          return ResponseEntity.created(uri).build();
      }
  
      @GetMapping(path = "/levels")
      public ResponseEntity&lt;?&gt; getParameterLevels() {
          return ResponseEntity.ok(ParameterLevels.getParameterLevelMap());
      }
  
      @GetMapping(path = "/levels/{id}/values")
      public ResponseEntity&lt;?&gt; getLevelValues(@PathVariable("id") int levelId) {
          return ResponseEntity.ok(parameterService.getParameterLevelValues(levelId));
      }
  
      @GetMapping(path = "/types")
      public ResponseEntity&lt;?&gt; getParameterTypes() {
          return ResponseEntity.ok(parameterService.getParameterTypes());
      }
  }
  </code></pre>
  
  <p>I was using axios from JavaScript and though my problem might be there but I have the same issue using Postman. I am setting the Content-Type and Accept header. It seems like Spring is not deserializing the data at all.</p>
  
  <p><a href="https://i.stack.imgur.com/Exp3h.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Exp3h.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/IXSNb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/IXSNb.png" alt="enter image description here"></a></p>