I need migrate from CloseableHttpClient to RestTemplate in my desctop client application. RestTemplate response has an empty "Set-cookie" header.
Source code (works ok): // returns the Set-Cookie header = "JSESSIONID=D2442..."
List<BasicNameValuePair> parameters = asList(
new BasicNameValuePair("username", username),
new BasicNameValuePair("password", password));
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(parameters));
CloseableHttpClient client = createDefault()
CloseableHttpResponse response = client.execute(httpPost);
Target code: // returns the Set-Cookie header = ""
String url = url;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> map= new LinkedMultiValueMap<>();
map.add("username", username);
map.add("password", password);
ParameterizedTypeReference<Map<String, String>> responseType = new ParameterizedTypeReference<>() {};
HttpEntity<Object> request = new HttpEntity<>(map, headers);
ResponseEntity<Map<String, String>> tokensInfo = restTemplate.exchange(
url, HttpMethod.POST, request, responseType
);
Help, please.