The solution can be found here https://github.com/spring-projects/spring-framework/issues/22734
you can create two separate post request mappings. For example.
@PostMapping(path = "/test", consumes = "application/json")
public String test(@RequestBody User user) {
return user.toString();
}
@PostMapping(path = "/test", consumes = "application/x-www-form-urlencoded")
public String test(User user) {
return user.toString();
}