【问题标题】:How to rewrite this code to use retrieve() method?如何重写此代码以使用retrieve() 方法?
【发布时间】:2020-12-20 18:09:14
【问题描述】:

如何重写这段代码以使用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-8' 不支持 bodyType=org.springframework.http.ResponseEntity

【问题讨论】:

    标签: spring-boot rest kotlin webclient


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2018-03-07
      • 2013-09-25
      • 1970-01-01
      • 1970-01-01
      • 2019-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多