Here is a very dramatic situation for me, I don't what mistake supplying payload to rest client, because of which I am getting "400: BAD REQUEST" exception. Below is the code please help me solve it,
@RequestMapping(value = "/uploadQuestionImg", method = RequestMethod.POST)
public ResponseEntity<FileMetadata> commonFileUpload(@RequestParam("file") MultipartFile file) {
FileMetadata fileInfo = null;
HttpStatus statusCode = HttpStatus.BAD_REQUEST;
if (!file.isEmpty()) {
try {
FileInfoService reqFile = createFileInfo(file, "");
fileInfo = (FileMetadata) operations.store(file.getInputStream(), reqFile);
statusCode = HttpStatus.OK;
} catch (Exception e) {
logger.warn("Exception occured", e);
statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
}
} else {
logger.warn("Invalid request");
}
return new ResponseEntity<FileMetadata>(fileInfo, statusCode);
}
Here is the payload I am passing to the rest client,