We Are Going To Discuss About Content type ‘multipart/form-data;boundary=—-…;charset=UTF-8’ not supported. So lets Start this Java Article.
Content type ‘multipart/form-data;boundary=—-…;charset=UTF-8’ not supported
- Content type 'multipart/form-data;boundary=—-…;charset=UTF-8' not supported
As said dknight @RequestBody means use of JSON or XML data with maps your DTO bean.
In case of MultipartFile you can't use JSON data so you can't use @RequestBody.
Try with @ModelAttribute annotation. - Content type 'multipart/form-data;boundary=—-…;charset=UTF-8' not supported
As said dknight @RequestBody means use of JSON or XML data with maps your DTO bean.
In case of MultipartFile you can't use JSON data so you can't use @RequestBody.
Try with @ModelAttribute annotation.
Solution 1
As said dknight @RequestBody means use of JSON or XML data with maps your DTO bean.
In case of MultipartFile you can’t use JSON data so you can’t use @RequestBody.
Try with @ModelAttribute annotation.
Working sample :
@PostMapping("/promoters")
@Timed
public ResponseEntity<PromoterDTO> createPromoter(@ModelAttribute PromoterDTO promoterDTO) throws URISyntaxException { ... }
With PromoterDTO like this :
public class PromoterDTO implements Serializable {
private Long id;
private String name;
private String address;
private MultipartFile logo;
}
Original Author uncleBounty Of This Content
Solution 2
In Postman, you need to set the body to be of type raw, and from the drop down you can select JSON, I had a similar issue, this fixed my issue.
Original Author plue Of This Content
Solution 3
Instead of @RequestBody
, use @RequestParam
!
Original Author Shadab Reza Of This Content
Solution 4
use @ModelAttribute instead of @ResponseBody as this takes up data in key value pairs and the later is used for an object like, json.
While hitting the api simply pass the multipart type and json key value pairs of the object. It works fine!
Original Author tushar Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.