title: Send PUT, DELETE HTTP request in HttpURLConnection
body: <p>I have created web service call using java below code. Now I need to make delete and put operations to be perform.   </p>
  
  <pre><code>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();
  </code></pre>
  
  <p>When I add below code to perform DELETE action it gives errors saying:</p>
  
  <blockquote>
    <p>java.net.ProtocolException: HTTP method DELETE doesn't support output. </p>
  </blockquote>
  
  <pre><code>conn.setRequestMethod( "DELETE" );
  </code></pre>
  
  <p>So how to perform delete and put requests?</p>