List of usage examples for org.apache.commons.httpclient.methods DeleteMethod getResponseBody
@Override public byte[] getResponseBody() throws IOException
From source file:org.apache.manifoldcf.examples.ManifoldCFAPIConnect.java
/** Perform an API DELETE operation. *@param restPath is the URL path of the REST object, starting with "/". *@return the json response.//from w w w .j a v a 2s .co m */ public String performAPIRawDeleteOperation(String restPath) throws IOException { HttpClient client = new HttpClient(); DeleteMethod method = new DeleteMethod(formURL(restPath)); int response = client.executeMethod(method); byte[] responseData = method.getResponseBody(); // We presume that the data is utf-8, since that's what the API // uses throughout. String responseString = new String(responseData, "utf-8"); if (response != HttpStatus.SC_OK) throw new IOException("API http error; expected " + HttpStatus.SC_OK + ", saw " + Integer.toString(response) + ": " + responseString); return responseString; }