restTemplate delete with body
<p>I am trying to do DELETE with request body but I keep getting 400 (bad request) error. When I do it in the swagger/postman, it is successfully deleting the record. But from the Java code I can't do that</p>

<p>The external API is designed in a way that it needs body along with URL. It can't be changed. please let me know how can I delete that entry with request body</p>

<pre><code>public Person delete(Person person, String url, Map&lt;String, String&gt; uriVariables) throws JsonProcessingException {
        RestTemplate restTemplate = new RestTemplate();
        CustomObjectMapper mapper = new CustomObjectMapper();
        HttpEntity&lt;Person&gt; requestEntity = new HttpEntity&lt;Person&gt;(person);
        try {
            ResponseEntity&lt;Person&gt; responseEntity = restTemplate.exchange(url, HttpMethod.DELETE, requestEntity, Person.class, uriVariables);
            return responseEntity.getBody();
        } catch (RestClientException e) {
            System.out.println(mapper.writeValueAsString(person));
            throw e;
        }
    }
</code></pre>

<p>when it goes to exception, I will get the JSON request in JSON format and the same works fine in Swagger/postman</p>

<p>I did some googling and found that restTemplate have problem deleting when there is request body. this article wasn't helpful <a href="https://jira.spring.io/browse/SPR-12361" rel="noreferrer">https://jira.spring.io/browse/SPR-12361</a> is there any way to get it work</p>