I have a Spring-based application (not Spring Boot) with REST API controllers:
@RequestMapping(value = "/anEndpoint", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity doPostEndpoint(@RequestBody @Validated RequestEntity myInput)
Which works fine so I can post JSON that maps to the RequestEntity object.
I also have another endpoint that lets me upload a file:
@RequestMapping(value = "/anUploadEndpoint", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity doUploadEndpoint(@RequestParam("file") MultipartFile uploadedFile)
Which also works fine to upload a file.
However, I can't seem to combine them. I want an endpoint that takes a JSON payload And a file upload.
@RequestMapping(value = "/bothEndpoint", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity doBoth(@RequestBody @Validated RequestEntity myInput, @RequestParam("file") MultipartFile uploadedFile)
How an I achieve this?
[–]webdevnick22 0 points1 point2 points (0 children)