我想通过localhost通过基于某些cookie的其他域发送Http请求。我尝试了以下代码,但它没有奏效。有人可以帮忙吗?
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
headers.add("Set-Cookie", "key=value");
MultiValueMap<String, String> requestData =
DataTransformation.transformSendVerificationRequest(sendVerificationCodeDTO);
HttpEntity<MultiValueMap<String, String>> httpEntity = new
HttpEntity(requestData, headers);
String url = this.serviceUrl;
ResponseEntity<SendVerificationCodeResponse> response =
this.restTemplate.exchange(url, HttpMethod.POST, httpEntity,
SendVerificationCodeResponse.class, new Object[0]);