I have a spring boot application with groovy (jdk 11), I want to accept a xml request body. This is my controller:
@RestController
class UserController {
@PostMapping(path = "/herd", produces = APPLICATION_XML_VALUE, consumes = APPLICATION_XML_VALUE)
void saveHerd(@RequestBody Users request) {
println user.name
}
}
My xml request body:
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user name="foo" age="4"/>
<user name="Jack" age="8"/>
</users>
The users pojos:
class Users {
List<UserDTO> user
}
class UserDTO {
String name
String age
}
The problem is that my request is returning a Content type 'application/xml;charset=UTF-8' not supported]
If I debug my application, I see that spring web is still expecting a json for some reason even if I have specified consumes to be XML.
Why is Spring-boot still expecting a json instead of an XML?