I have Feign client in one service with a method
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
MyDto uploadDocument(@RequestPart("file") MultipartFile file,
@RequestPart("myDto") String myDto);
I have a controller in another service
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<MyDto> uploadDocument(@RequestParam("file") MultipartFile file,
@RequestPart("myDto") MyDto myDto) {
.... some code here
}
The issue I faced is that Feign sends myDto with Content-type : text/plain and I have HttpMediaTypeNotSupportedException
Is it possible to send @RequestPart("myDto") String myDto
with Content-type : application/json ?
expected Raw request:
----------------------------boundary
Content-Disposition: form-data; name="file"; filename="fileName"
<file>
----------------------------boundary
Content-Disposition: form-data; name="myDto"
**Content-Type: application/json**
{"myDto": ""}
Current raw request:
----------------------------boundary
Content-Disposition: form-data; name="file"; filename="fileName"
<file>
----------------------------boundary
Content-Disposition: form-data; name="myDto"
**Content-Type: text/plain**
{"myDto": ""}
myDto
in yourFeign
client fromString
toMyDto
? – Aukfeign-form
– Auk