is there a way an incoming text/plain contant type which contains a valid JSON doc can be received automatically into a bean DTO/Model
Right now I am having to receive as a string and then use an Object Mapper (see far below). When I tried to use a bean in the signature it gave
{
"type": "https://www.jhipster.tech/problem/problem-with-message",
"title": "Unsupported Media Type",
"status": 415,
"detail": "Content type 'text/plain;charset=UTF-8' not supported",
"path": "/api/circle/notification",
"message": "error.http.415"
}
@PostMapping(path = "/circle/notification", produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_PLAIN_VALUE}, consumes = {MediaType.TEXT_PLAIN_VALUE})
public String event(@RequestBody String notification) throws URISyntaxException {
log.debug("REST request to post Circle notification : {}", notification);
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode root = objectMapper.readTree(notification);
log.debug("json root : {}", root.toString());
} catch (Exception ex) {
log.error("notification error {}", ex.toString());
}
return "OK";
}