I have a client program in which i make a HTTPURLConnection to a RESTful web service. I am passing all JSON data in the http request object. Everything seems to work fine for the HTTP POST/GET method but not for the DELETE method. When i execute the following code to delete a record, I am running into this exception...
java.net.ProtocolException: HTTP method DELETE doesn't support output
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1081)
My java code is this
URL url = new URL("http://example.com/api/indexer/v1/delete");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("DELETE");
conn.setRequestProperty("Content-Type", "application/json");
String input = "{\"ref\" : 123456}";
OutputStream os = conn.getOutputStream();
os.write(input.getBytes());
os.flush();
System.out.println(conn.getResponseCode() );
So How to perform operation delete. WEbservice requests parameter input.