Last active
September 12, 2018 19:49
-
-
Save sandipchitale/9e3c45ad320757dcd0f12ed85ccb82e2 to your computer and use it in GitHub Desktop.
Post with RestTemplate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RestTemplate restTemplate = new RestTemplate(); | |
HttpHeaders headers = new HttpHeaders(); | |
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | |
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); | |
// add to map the form parameters | |
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers); | |
try { | |
restTemplate.postForEntity(url, request, String.class); | |
} catch (RestClientException e) { | |
handleRestClientException(e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment