Get API response error message using Web Client Mono in Spring Boot : <p>I am using webflux Mono (in Spring boot 5) to consume an external API. I am able to get data well when the API response status code is 200, but when the API returns an error I am not able to retrieve the error message from the API. Spring webclient error handler always display the message as </p>

<p><code>ClientResponse has erroneous status code: 500 Internal Server Error</code>, but when I use PostMan the API returns this JSON response with status code 500.</p>

<pre><code>{
 "error": {
    "statusCode": 500,
    "name": "Error",
    "message":"Failed to add object with ID:900 as the object exists",
    "stack":"some long message"
   }
}
</code></pre>

<p>My request using WebClient is as follows</p>

<pre><code>webClient.getWebClient()
            .post()
            .uri("/api/Card")
            .body(BodyInserters.fromObject(cardObject))
            .retrieve()
            .bodyToMono(String.class)
            .doOnSuccess( args -&gt; {
                System.out.println(args.toString());
            })
            .doOnError( e -&gt;{
                e.printStackTrace();
                System.out.println("Some Error Happend :"+e);
            });
</code></pre>

<p>My question is, how can I get access to the JSON response when the API returns an Error with status code of 500?</p>
