Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the Android Apache HttpDelete class with parameter

Tags:

java

android

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);
like image 686
Claudio Ferraro Avatar asked Mar 22 '23 09:03

Claudio Ferraro


1 Answers

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);
like image 61
EJK Avatar answered Apr 01 '23 10:04

EJK