send request with body - RestTemplate

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

MultiValueMap<String, String> data = new LinkedMultiValueMap<String, String>(); 
data.add("client_id",clientId); 
data.add("client_secret",clientSecret); 
data.add("grant_type",grantType); 
data.add("redirect_uri",redirectUrl); 
data.add("code",code.split("#")[0]); 

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

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

Comments

Popular posts from this blog

Validation for AZ phone numbers with RegEx in Java

Java necə işləyir, kod nədir ?