错误描述信息:
HTTP/1.1 200 OK [Server: nginx/1.14.0, Date: Thu, 28 Jun 2018 09:49:02 GMT, Content-Type: application/json; charset=utf-8, Content-Length: 34, Connection: keep-alive, Cache-Control: no-cache, Pragma: no-cache, Expires: -1, X-AspNet-Version: 4.0.30319, X-Powered-By: ASP.NET]
代码:
{完整的HttpDelete请求}
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
public static String sendDelete(String url, String Json) {
HttpResponse response = null;
String result = null;
try {
HttpEntity entity = new StringEntity(Json);
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpDeleteWithBody httpDeleteWithBody = new HttpDeleteWithBody(url);
httpDeleteWithBody.setHeader("Content-Type", "application/json; charset=UTF-8");
httpDeleteWithBody.setEntity(entity);
response = httpClient.execute(httpDeleteWithBody);
//关键代码
result = EntityUtils.toString(response.getEntity());
} catch (Exception e) {
e.printStackTrace();
}
return result;
}