0

Below is the implementation for status code from clientResponse

webclient.put().uri(url).header(header -> header.putAll(headers)).body(BodyInserters.fromValue(request)).retrieve().onStatus(HttpStatus :: isError, clientResponse -> {
    if(clientResponse.statusCode == HttpStatus.NOT_FOUND){
        throw new ResourceNotFoundException();
    }else {
        throw new AppException();
    }
})

and now I wanted to get response body on error from client Response because I have to provide response as same as received response body on error from API call.

  • Does this answer your question? [Getting the response body in error case with Spring WebClient](https://stackoverflow.com/questions/71643036/getting-the-response-body-in-error-case-with-spring-webclient) – Alex Mar 08 '23 at 05:33

0 Answers0