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.