List of usage examples for org.apache.http.client.methods HttpDelete HttpDelete
public HttpDelete(final String uri)
From source file:com.javaquery.apache.httpclient.HttpDeleteExample.java
public static void main(String[] args) { /* Create object of CloseableHttpClient */ CloseableHttpClient httpClient = HttpClients.createDefault(); /* Prepare delete request */ HttpDelete httpDelete = new HttpDelete("http://www.example.com/api/customer"); /* Add headers to get request */ httpDelete.addHeader("Authorization", "value"); /* Response handler for after request execution */ ResponseHandler<String> responseHandler = new ResponseHandler<String>() { @Override//from ww w .ja v a 2 s .co m public String handleResponse(HttpResponse httpResponse) throws ClientProtocolException, IOException { /* Get status code */ int httpResponseCode = httpResponse.getStatusLine().getStatusCode(); System.out.println("Response code: " + httpResponseCode); if (httpResponseCode >= 200 && httpResponseCode < 300) { /* Convert response to String */ HttpEntity entity = httpResponse.getEntity(); return entity != null ? EntityUtils.toString(entity) : null; } else { return null; /* throw new ClientProtocolException("Unexpected response status: " + httpResponseCode); */ } } }; try { /* Execute URL and attach after execution response handler */ String strResponse = httpClient.execute(httpDelete, responseHandler); /* Print the response */ System.out.println("Response: " + strResponse); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:com.javaquery.aws.elasticsearch.DeleteExample.java
public static void main(String[] args) { /**/*from w w w. ja va 2 s . c o m*/ * Amazon ElasticSearch Service URL: * endpoint + / + {index_name} + / + {type} + / + {id} */ String elastic_search_url = "http://xxxxx-yyyyy-r6nvlhpscgdwms5.ap-northeast-1.es.amazonaws.com/inventory/simple/123"; /* Prepare delete request */ HttpDelete httpDelete = new HttpDelete(elastic_search_url); /* Execute delete request */ httpDeleteRequest(httpDelete); }
From source file:core.RESTCalls.RESTDelete.java
public static String httpDelete(String urlStr) { HttpClient client = new DefaultHttpClient(); HttpDelete delete = new HttpDelete(urlStr); String result = null;//from w w w . j av a 2s .co m try { HttpResponse response = client.execute(delete); if (response != null && response.getEntity() != null) { BufferedReader r = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuilder total = new StringBuilder(); String line = null; while ((line = r.readLine()) != null) total.append(line + "\n"); result = total.toString(); } } catch (Exception ex) { ex.printStackTrace(); } return result; }
From source file:com.github.rnewson.couchdb.lucene.couchdb.HttpUtils.java
public static final int delete(final HttpClient httpClient, final String url) throws IOException { return httpClient.execute(new HttpDelete(url), new StatusCodeResponseHandler()); }
From source file:com.bjorsond.android.timeline.sync.ServerDeleter.java
protected static void deleteUserFromGroupToGAE(Group groupToRemoveMember, User userToRemoveFromGroup) { final HttpDelete httpDelete = new HttpDelete("/rest/group/" + groupToRemoveMember.getId() + "/user/" + userToRemoveFromGroup.getUserName() + "/"); httpDelete.addHeader(CoreProtocolPNames.USER_AGENT, "TimelineAndroid"); sendDeleteRequestTOGAEServer("", Constants.targetHost, httpDelete); }
From source file:com.spokenpic.net.RestClientDelete.java
@Override protected RestResult doGet() { HttpDelete httpDelete = new HttpDelete(getSchemeServer() + this.uri); setupHttp(httpDelete);// w ww. j a va 2s. c om try { HttpResponse httpResponse = HttpManager.execute(httpDelete); return returnResponse(httpResponse); } catch (Exception e) { Log.d("RestClientDelete", "Error doGet (delete) " + e.toString()); return errorResponse("Fatal error during DELETE"); } }
From source file:com.bjorsond.android.timeline.sync.ServerDeleter.java
protected static void deleteUserFromGroupToGAE(Group selectedGroup) { final HttpDelete httpDelete = new HttpDelete("/rest/group/" + selectedGroup.getId() + "/"); sendDeleteRequestTOGAEServer("", Constants.targetHost, httpDelete); }
From source file:com.deployd.Deployd.java
public static JSONObject delete(String uri) throws ClientProtocolException, IOException, JSONException { HttpDelete post = new HttpDelete(endpoint + uri); HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(post); ByteArrayEntity e = (ByteArrayEntity) response.getEntity(); InputStream is = e.getContent(); String data = new Scanner(is).next(); JSONObject result = new JSONObject(data); return result; }
From source file:com.ea.core.bridge.ws.rest.client.DeleteClient.java
@Override protected HttpRequestBase getMethod(String url) { // TODO Auto-generated method stub return new HttpDelete(url); }
From source file:org.talend.dataprep.api.service.command.preparation.PreparationDeleteAction.java
private PreparationDeleteAction(final String preparationId, final String stepId) { super(GenericCommand.PREPARATION_GROUP); execute(() -> new HttpDelete( preparationServiceUrl + "/preparations/" + preparationId + "/actions/" + stepId)); //$NON-NLS-1$ //$NON-NLS-2$ on(HttpStatus.OK).then(asNull());/*from ww w.j a v a 2 s. co m*/ }