Reputation: 3252
my question is very simple, It's possibily use two different content-type headers on the same method?
like that:
@RequestMapping(value = "/provider", method = RequestMethod.POST, headers = "Accept=application/json,content-type=multipart/form-data")
@ResponseBody
@Transactional
public ResponseEntity<String> createProviderQuote(
@RequestParam(value = "work", required = true) String workId,
UriComponentsBuilder uriComponentsBuilder, final HttpServletRequest request) {
}
I need to send a Json Object with Images (Multipart Files), but I have not succeeded. For that reason I use headers:
headers = "Accept=application/json,content-type=multipart/form-data"
Many Thanks!
Upvotes: 1
Views: 2097
Reputation: 13571
Yes, you can - for setting what your endpoint will accept and return you need to use consumes
and produces
attributes od @RequestMapping
annotation like
@RequestMapping(value = "/provider",
method = RequestMethod.POST,
produces = {MediaType.APPLICATION_JSON, MediaType.MULTIPART_FORM_DATA})
Of course then you need to properly support this on frontend side due to your requirements
Upvotes: 1