Claudio Ferraro
Claudio Ferraro

Reputation: 4721

How to use the Android Apache HttpDelete class with parameter

I need to send an ID to the server and have the server to delete one record in a DB. I want to use the HttpDelete Apache Android SDK integrated class but I cannot figure out how to use it and how to pass parameters to the server. With the POST request I use .setEntity method on the HttpPost class. But in HttpDelete there's no .setEntity method.

What I have so far achieved is:

 HttpClient httpclient = new DefaultHttpClient();
 HttpDelete httpdelete = new HttpDelete(url);
 httpdelete.setHeader(HTTP.CONTENT_TYPE, "text/xml");
 response = httpclient.execute(httpdelete);

Upvotes: 4

Views: 2691

Answers (1)

EJK
EJK

Reputation: 12534

HTTP DELETE requests do not have a body. You pass parameters right on the URL:

 String url = "http://foo.com/bar?bing=bang"
 HttpDelete httpdelete = new HttpDelete(url);

Upvotes: 7

Related Questions