RestClientException: Could not extract response. no suitable HttpMessageConverter found

后端 未结 11 2211
感情败类
感情败类 2020-12-13 08:17

Using the curl command:

curl -u 591bf65f50057469f10b5fd9:0cf17f9b03d056ds0e11e48497e506a2 https://backend.tdk.com/api/devicetypes/59147fd79e93s12e61499ffe/me         


        
11条回答
  •  被撕碎了的回忆
    2020-12-13 08:45

    In my case @Ilya Dyoshin's solution didn't work: The mediatype "*" was not allowed. I fix this error by adding a new converter to the restTemplate this way during initialization of the MockRestServiceServer:

      MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = 
                          new MappingJackson2HttpMessageConverter();
      mappingJackson2HttpMessageConverter.setSupportedMediaTypes(
                                        Arrays.asList(
                                           MediaType.APPLICATION_JSON, 
                                           MediaType.APPLICATION_OCTET_STREAM));
      restTemplate.getMessageConverters().add(mappingJackson2HttpMessageConverter);
      mockServer = MockRestServiceServer.createServer(restTemplate);
    

    (Based on the solution proposed by Yashwant Chavan on the blog named technicalkeeda)

    JN Gerbaux

提交回复
热议问题