Issue
I created a restful api to upload a file to an external web service, but I need to send some kind of data in this request to, here is an example of the request :
"file" : <MultiPartFile>,
"data" : {...}
I mapped this request to this class :
@Data
class UploadFileRequest{
private MultiPartFile file;
private Data data;
}
here is the api :
@PostMapping
String uploadFile(@RequestBody UploadFileRequest input){
return service.uploadFile(input.getFile(), input.getData());
}
I want to know how to send this kind of request.
Solution
To test file upload in postman you just need to set the body to form-data
and use type file
to upload a file. I've tested this with Postman Echo and published an example that you can copy to your collection.
If you navigate to my example you're simply going to find this:
Answered By - bitoiu
Answer Checked By - Pedro (JavaFixing Volunteer)