I have this mock controller:
@GetMapping(value = "/mock", produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<BodyResponseDTO> getMock() {
try {
BodyResponseDTO bodyResponseDTO = new BodyResponseDTO();
bodyResponseDTO.setCode(HttpStatus.OK.toString());
bodyResponseDTO.setMessage("Risposta OK");
return new ResponseEntity<>(bodyResponseDTO, HttpStatus.OK);
} catch (Exception e) {
log.error("Errore: ", e.getCause());
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
the exception is: Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class com.consumer.message.BodyResponseDTO] with preset Content-Type 'null']
Keep in mind that I build the http headers in this method:
private HttpHeaders buildHttpHeaders(HeaderRequestDTO headerRequest) {
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", headerRequest.getAccept());
headers.set("Agid-JWT-Signature", headerRequest.getAgIDJWTSignature());
headers.set("Authorization", headerRequest.getAuthorization());
headers.set("Content-Type", headerRequest.getContentType());
headers.set("If-Match", headerRequest.getIfMatch());
headers.set("Content-Range", headerRequest.getContentRange());
return headers;
}
and the Accept headers is often if not always "text/plain"
How to solve this exception? Thanks in advance