79269988

Date: 2024-12-10 22:33:49
Score: 0.5
Natty:
Report link

As I understand, you're trying to handle a multipart file as well. Have you tried using @RequestPart? It allows you to separate the multipart file from the JSON object and handle it as a separate parameter.

I think, handling both a multipart file and JSON payload together isn't natively supported in Spring, as @RequestBody is designed to handle a single, serialized JSON object in the request body.

@PutMapping(value = "/submit", consumes = "multipart/form-data")
public ResponseEntity<FormData> submit(
@RequestPart Submission submission, @RequestPart MultipartFile file) throws IOException {}
Reasons:
  • Whitelisted phrase (-1): Have you tried
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • User mentioned (1): @RequestPart
  • User mentioned (0): @RequestBody
  • Low reputation (1):
Posted by: ragav ravi