0

I want to pass a hosted file over the rest template to another end point. I have to pass the hosted file URL as a String.

See the below code.

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
map.add(ATTACHMENT,new FileSystemResource(request.getAttachment()));
HttpEntity<MultiValueMap<String,Object>> outBoundRequest = new HttpEntity<>(map, headers);
return restTemplate.exchange(uri[0],HttpMethod.POST,outBoundRequest,Response.class);

Suppose I am passing "http://www.africau.edu/images/default/sample.pdf";

Why I am getting "Illegal char <:> at index 4: http:\www.africau.edu\images\default\sample.pdf"?

Can anyone help me out here.

Thanks, Dasun.

D.Anush
  • 147
  • 6
  • 15
  • Just a suggestion, but you should move away from `RestTemplate` if you can - it is being deprecated and `WebClient` is being recommended to use – Ascalonian Sep 04 '22 at 05:19

0 Answers0