I have created web service call using java below code. Now I need to make delete and put operations to be perform.
URL url = new URL("http://example.com/questions");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod( "POST" );
conn.setRequestProperty("Content-Type", "application/json");
OutputStream os = conn.getOutputStream();
os.write(jsonBody.getBytes());
os.flush();
When I add below code to perform DELETE action it gives errors saying:
java.net.ProtocolException: HTTP method DELETE doesn't support output.
conn.setRequestMethod( "DELETE" );
So how to perform delete and put requests?
PUT
example usingHttpURLConnection
:DELETE
example usingHttpURLConnection
: