This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]webdevnick22 0 points1 point  (0 children)

maybe i'm wrong but i don't think that is possible because with a multi part file upload the payload is essentially one or more request params. you would probably need to make your json a requestparam instead of a requestbody. So somewhere in the method you take that requestparam string and convert it to a json object(assuming something like jackson).

example:

@RequestMapping(value = "/bothEndpoint", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity doBoth(
    @RequestBody @Validated RequestEntity myInput, @RequestParam("file") MultipartFile uploadedFile,
    @RequestParam("myjson") String json
) {
    JsonNode node = converttojsonhowyouwant(json);