Below snippet
performs PUT request.
public static ResponseEntity<String> put(String url, Map<String, String> headers, String json) {
if (url == null || url.isEmpty()) {
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("URL must not be null");
}
HttpHeaders httpHeaders = getHeadersFromMap(headers);
//httpHeaders.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Object> httpEntity = new HttpEntity<Object>(json, httpHeaders);
return REST_TEMPLATE.exchange(url, HttpMethod.PUT, httpEntity, String.class);
}
You can
download complete working application from this link.
No comments:
Post a Comment