Friday, 20 September 2019

RestTemplate: DELETE Request Example


public static ResponseEntity<String> delete(String url, Map<String, String> headers) {
 if (url == null || url.isEmpty()) {
  return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("URL must not be null");
 }

 HttpHeaders httpHeaders = getHeadersFromMap(headers);

 HttpEntity<Object> httpEntity = new HttpEntity<Object>(httpHeaders);

 return REST_TEMPLATE.exchange(url, HttpMethod.DELETE, httpEntity, String.class);

}
You can get the complete working application from this link.



Previous                                                    Next                                                    Home

No comments:

Post a Comment