*/
public String performAPIDeleteOperation(String apiURL, int expectedResponse)
throws Exception
{
DefaultHttpClient client = new DefaultHttpClient();
HttpDelete method = new HttpDelete(apiURL);
try
{
HttpResponse response = client.execute(method);
int responseCode = response.getStatusLine().getStatusCode();
String responseString = convertToString(response);
if (responseCode != expectedResponse)
throw new Exception("API http error; expected "+Integer.toString(expectedResponse)+", saw "+Integer.toString(responseCode)+": "+responseString);
// We presume that the data is utf-8, since that's what the API uses throughout.
return responseString;
}
finally
{
method.abort();
}
}