I'm creating a new endpoint to upload and process excel and csv files. I'm trying to create an endpoint using springs Multipart upload, but I cannot reach the endpoint from Postman or using curl in command line.
I have a RestController
@RestController
@RequestMapping("/v1/finance/ratecard")
public class RateCardController
and I am able to access other endpoints in this controller without a problem. I added new endpoint to this controller.
@PostMapping(value = "/uploadFile")
@ResponseStatus(HttpStatus.OK)
public void uploadExcelFile(@RequestPart("file") MultipartFile file, @RequestPart("meta-data") UploadRateCardRequest uploadRateCardRequest) {
//Unrelated logic here
}
And I'm trying to send POST request using postman, I haven't touched Content-Type header, it's generated by Postman, but I have had no success reaching it. I always get 404 error. Postman Config
I have tried adding consumes = "multipart/mixed" and "multipart/form-data" to @PostMapping annotation, but those changes had no effect.
What am I doing wrong? Am I missing some obvious request parameter in Postman, or is my controller set up wrong?
I had problems in uploadExcelFile
method, one of dependencies I was using could not detect valid beans for an autowired interface. That was causing this issue.
Nothing was wrong with Controller set up or postman config pictured in the post.