问题描述
suspend fun getEntity(): ResponseEntity<EntityDto> {
return restClient
.get()
.uri { ... }
.accept(MediaType.APPLICATION_JSON)
.awaitExchange()
.awaitEntity()
}
当我使用retrieve()时,我收到以下错误:
org.springframework.web.reactive.function.UnsupportedMediaTypeException: 内容类型 'application/json;charset=UTF-8' 不支持 bodyType=org.springframework.http.ResponseEntity
解决方法
您指定的内容类型与响应中的内容类型不匹配。检查响应中的内容类型并为 .accept(MediaType.APPLICATION_JSON)
使用适当的类型。还要检查在该调用期间是否发生错误,以便整个预期响应因错误而不匹配。