RestTemplate delete with authentication using headers in Spring
To delete a resource using RestTemplate we can use its method that uses HTTP DELETE method.
RestTemplate has two methods that can use HTTP DELETE method.
When we use RestTemplate.delete(), we are not able to pass headers for authentication. But if we use RestTemplate.exchange(), we can achieve our goal as follows.
restTemplate.exchange(url, HttpMethod.DELETE, request, Void.class, 1);