Configure HTML/JavaScript

Showing posts with label delete method of restfull web services extending httpPost. Show all posts
Showing posts with label delete method of restfull web services extending httpPost. Show all posts

Thursday, April 14, 2016

How to add request body to http Delete method


Http Methods methods:


While consuming web services, many tume we need to call http put, delete, get, post methods. While calling http het and post methods are regularly used and you need minimal configuration, put, delete, etc methods some time confuse developer.

Problem with Http Delete methods:


In case of http delete methods, we cannot send request body if your are using http client. it does not allow to do as there is no methods avaialble.

You will face this problem in case you are developing an application where you web service end point need some data in the delete methods and in clent there are no ways to do that.

Soloutions:


The solution is to extend the http post method and change the method to DELETE while sending data. One of the easiest way I would suggest is as below.

Extend the HttpPost method and change the method to DELETE as below and then create the object of HttpPost rather HttpDelete.