RestClientException: Could not extract response. no suitable HttpMessageConverter found

后端 未结 11 2201
感情败类
感情败类 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 09:02

    Here is the approach I follow whenever I see this type of error:

    1. One way to debug this issue is by first taking whatever response is coming as String.class then applying Gson().fromJson(StringResp.body(), MyDTO.class). It will still fail most probably but this time it will throw the fields which are creating this error to happen in first place. Post the modification, we can use the previous approach as usual.

    ResponseEntity respStr = restTemplate.exchange(URL,HttpMethod.GET, entity, String.class);
    Gson g = new Gson();

    The below step will throw error with the fields which is causing the issue

    MyDTO resp = g.fromJson(respStr.getBody(), MyDTO.class);
    

    I don't have the error message with me but it will point to the field which is problematic and the reason for it. Resolve those and try again with previous approach.

提交回复
热议问题