I have this code :
ResponseEntity<DTODemo> responseEntity = webClient.get()
.uri("http://localhost:8051/callAPI/")
.retrieve()
.toEntity(DTODemo.class)
.block();
It work, when my api return an object DTODemo
.
But, the API can return with code HTTP 404 a message in the body ( type String).
I have this exception :
org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'text/plain;charset=UTF-8' not supported for bodyType=com.example.demo.DTODemo
I try many of things but i haven't found a good solution.
Any idea to solve my problem using retrieve and not exchange ?
Thanks a lot.