Reputation: 197
I am trying to convert my jersey api call to spring boot resttemplate client call, when i am trying to add vender specific header its saying unsupported media type. i tried like this
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.ALL));
headers.setContentType(MediaType.ALL);
HttpEntity<String> entity = new HttpEntity<String>("parameters", headers);
ResponseEntity<Admin> result = restTemplate.exchange(url, HttpMethod.GET, entity, Admin.class);
i even tried diffrent combinations of Media types but it did not worked i also tried to add media type like MediaType.parseMediaType("application/vnd.....);
please provide some help in this.please let me know what is httpMessage converter and how to add this to our custom vender specific media types.
Upvotes: 2
Views: 1833
Reputation: 15253
You won't be able to set a custom content type with setContentType(MediaType mediaType)
since it accepts a MediaType
object, which your custom MediaType cannot be converted into.
You can use the below to set the custom content type:
headers.set(HttpHeaders.CONTENT_TYPE,"application/custom");
Upvotes: 3
Reputation: 522
Use:
headers.setContentType(MediaType.valueOf(VENDOR_MEDIA_TYPE));
Upvotes: 0