如何重写此代码以使用retrieve()方法



如何重写此代码以使用retrieve((方法?

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-8bodyType=org.springframework.http.ResponseEntity

您指定的内容类型与响应中的内容类型不匹配。检查响应中的内容类型,并为.accept(MediaType.APPLICATION_JSON)使用适当的内容类型。还要检查该调用过程中是否发生了错误,从而使整个预期响应因错误而不匹配。

相关内容

最新更新