spring boot feign client returns "FileUploadException: the request was rejected because no multipart boundary was found"

1.3k views Asked by At

I'm getting stuck with uploading the file using feign client, which returns "FileUploadException: the request was rejected because no multipart boundary was found". which works with postman correctly.

feign client request headers:

  • content-type = multipart/form-data
  • accept = /
  • user-agent = Java/11.0.8
  • host = localhost:8585
  • connection = keep-alive

Postman request headers:

  • user-agent = PostmanRuntime/7.26.5
  • accept = /
  • postman-token = ee6c2ec3-bbbc-41ed-82c4-627563fd3323
  • host = localhost:8585
  • accept-encoding = gzip, deflate, br
  • connection = keep-alive
  • content-type = multipart/form-data; boundary=--------------------------812970255600377379110971
  • content-length = 173

my client code:

@RequestMapping(value = "api/v1/fileTransfer/upload/reports", headers = ("content-type=multipart/form-data; boundary=--------------------------812970255600377379110971"), method = RequestMethod.POST,
        consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
FileUploadResponseDTO fileUpload(@RequestPart(value = "files") MultipartFile[] files);

my controller:

@RequestMapping(value = "/api/v1/fileTransfer/upload/reports", method = RequestMethod.POST)
public ResponseEntity uploadFile(
        @RequestPart(value = "files")
                MultipartFile[] files){
          return new ResponseEntity(HttpStatus.ACCEPTED);

I know there is a lot of questions regarding this. I worked with them for the whole day. what they are saying is just put content-type = multipart/form-data. but it didn't work for me.

0

There are 0 answers