I need to pass a request body to make a delete request in order to call a third-party API's delete Request. Is it possible?
Asked
Active
Viewed 349 times
0
-
Did you get a chance to look at this question https://stackoverflow.com/questions/25375046/passing-data-in-the-body-of-a-delete-request – null Sep 12 '21 at 05:47
2 Answers
2
The specification RFC 7231 doesn't prevent from accepting a RequestBody in DELETE method.
A payload within a DELETE request message has no defined semantics; sending a payload body on a DELETE request might cause some existing implementations to reject the request.
You can accept Request Body if the underlying web server is configured to parse the body for DELETE method.

null
- 548
- 3
- 14
-
I understand your point but I had to connect a 3rd party API which was designed the way I asked in my question. – PKS Sep 13 '21 at 11:10
0
So I have found the way that I was searching for. The problem can be solved using Rest template
RestTemplate restTemplate = new RestTemplate();
HttpEntity<Model> request = new HttpEntity<>(new Model("data"));
restTemplate.exchange(url, HttpMethod.DELETE, request, null);

PKS
- 618
- 1
- 7
- 19