Prior to asking this, I am already tried using:
<code>log.error("fail {} ", ex.getResponseBodyAsString());
</code>
<code>log.error("fail {} ", ex.getResponseBodyAsString());
</code>
log.error("fail {} ", ex.getResponseBodyAsString());
I am already attaching .defaultStatusHandler()
on the restClient. which is not really helping when debugging or logging the error. What I want is a clear and readable httpResponse like what we see it on the Postman.
Currently, I doing:
<code>aRestClient.post()
.uri(turl)
.body(request)
.retrieve()
.onStatus(httpStatusCode -> httpStatusCode.value()== 400, (req, res) -> {
System.out.printf(Arrays.toString(res.getBody().readAllBytes()));
})
.body(LivinPointConvertResponse.class);
</code>
<code>aRestClient.post()
.uri(turl)
.body(request)
.retrieve()
.onStatus(httpStatusCode -> httpStatusCode.value()== 400, (req, res) -> {
System.out.printf(Arrays.toString(res.getBody().readAllBytes()));
})
.body(LivinPointConvertResponse.class);
</code>
aRestClient.post()
.uri(turl)
.body(request)
.retrieve()
.onStatus(httpStatusCode -> httpStatusCode.value()== 400, (req, res) -> {
System.out.printf(Arrays.toString(res.getBody().readAllBytes()));
})
.body(LivinPointConvertResponse.class);
which yield:
<code>[123, 34, 99, 111, 100, 101, 34, 58, 49, 53, 44, 34, 109, 101, 115, 115, 97, 103, 101, 83, 116, 114, 34, 58, 34, 77, 97, 97, 102, 44, 32, 74, 117, 109, 108, 97, 104, 32, 109, 105, 110, 105, 109, 117, 109, 32, 112, 101, 110, 117, 107, 97, 114, 97, 110, 32, 54, 32, 76, 105, 118, 105, 110, 39, 112, 111, 105, 110, 34, 44, 34, 115, 117, 99, 99, 101, 115, 115, 34, 58, 102, 97, 108, 115, 101, 44, 34, 100, 97, 116, 97, 34, 58, 110, 117, 108, 108, 125]
</code>
<code>[123, 34, 99, 111, 100, 101, 34, 58, 49, 53, 44, 34, 109, 101, 115, 115, 97, 103, 101, 83, 116, 114, 34, 58, 34, 77, 97, 97, 102, 44, 32, 74, 117, 109, 108, 97, 104, 32, 109, 105, 110, 105, 109, 117, 109, 32, 112, 101, 110, 117, 107, 97, 114, 97, 110, 32, 54, 32, 76, 105, 118, 105, 110, 39, 112, 111, 105, 110, 34, 44, 34, 115, 117, 99, 99, 101, 115, 115, 34, 58, 102, 97, 108, 115, 101, 44, 34, 100, 97, 116, 97, 34, 58, 110, 117, 108, 108, 125]
</code>
[123, 34, 99, 111, 100, 101, 34, 58, 49, 53, 44, 34, 109, 101, 115, 115, 97, 103, 101, 83, 116, 114, 34, 58, 34, 77, 97, 97, 102, 44, 32, 74, 117, 109, 108, 97, 104, 32, 109, 105, 110, 105, 109, 117, 109, 32, 112, 101, 110, 117, 107, 97, 114, 97, 110, 32, 54, 32, 76, 105, 118, 105, 110, 39, 112, 111, 105, 110, 34, 44, 34, 115, 117, 99, 99, 101, 115, 115, 34, 58, 102, 97, 108, 115, 101, 44, 34, 100, 97, 116, 97, 34, 58, 110, 117, 108, 108, 125]