Capturing response body - Web Client 400 bad request

60 Views Asked by At

How can I capture the response body of bad request - see img attached.

enter image description here

1

There are 1 best solutions below

0
f1sh On BEST ANSWER

If you catch this Exception as the WebClientResponseException that it obviously is, you can use a method that returns the body.

} catch(WebClientResponseException e) {
  String responseBody = e.getResponseBodyAsString();
  //log it?
}