728x90

Spring RestTemplate으로 양식 데이터를 POST하는 방법

 

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

MultiValueMap<String, String> map= new LinkedMultiValueMap<String, String>();
map.add("email", "first.last@example.com");

HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);

ResponseEntity<String> response = restTemplate.postForEntity( url, request , String.class );

 

https://stackoverflow.com/questions/38372422/how-to-post-form-data-with-spring-resttemplate

 

How to POST form data with Spring RestTemplate?

I want to convert the following (working) curl snippet to a RestTemplate call: curl -i -X POST -d "email=first.last@example.com" https://app.example.com/hr/email How do I pass the email parameter

stackoverflow.com

 

728x90

+ Recent posts