I am using spring boot version = 1.5.2.RELEASE. When I am sending multi part file with json object to upload file in postman, It throwing 415 Unsupported Media Type exception.
This is my controller class.
@RestController
@RequestMapping("/service/promotion/")
public class JobController {
....
....
....
@RequestMapping(value = "/job/test", method = RequestMethod.POST, produces = "application/json", consumes = "multipart/form-data")
public ResponseEntity<Object> createJobTest(@Valid @RequestBody JobRequest jobRequest,
@RequestParam(value = "file", required = false) MultipartFile multiPartFile) throws Exception {
My json request class.
public class JobRequest {
private String campaignKey;
private String communicationId;
private Integer channelId;
private String templateType;
private String subject;
private String frequencyControl;
private Integer leadsRequested;
private String keywordRelavance;
private String scheduledAt;
private String file;
private String updatedBy;
//getter and setter
}
Multipart file request in postman
But when I removed consumes from controller class and from postman as well like
@RequestMapping(value = "/job/test", method = RequestMethod.POST, produces = "application/json")
then debugger coming in controller class but multi part file value coming null in request object like
I googled a lot there are many similar questions which already posted but none of them helped me. Please help me to sort out this mystery.
Thank you.