0

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.

admlz635
  • 1,001
  • 1
  • 9
  • 18
  • https://stackoverflow.com/questions/4083702/posting-a-file-and-associated-data-to-a-restful-webservice-preferably-as-json – PeterMmm Aug 12 '22 at 09:06

1 Answers1

0

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:

enter image description here

bitoiu
  • 6,893
  • 5
  • 38
  • 60