In this post under Spring RestTemplate, I will show with example how to perform DELETE Http request.
To perform DELETE http request, we call “delete” method of “RestTemplate”. This method takes only the url with parameter map as optional.
Below is the complete main code for your reference
Main class
package package3;
import org.springframework.web.client.RestTemplate;
public class Example3 {
public static void main(String[] args) {
RestTemplate restTemplate = new RestTemplate();
String url = "http://jsonplaceholder.typicode.com/posts/1";
restTemplate.delete(url);
}
}
In the above code, at line 7, I create an instance of “RestTemplate”
At line 8, I define the url.
At line 9, I call “delete” method on the url to perform DELETE http request.
In this way we can make a DELETE http request.