spring-cloud-openfeign: Multiple @RequestPart not Working
Hi,
Below is my technology stack: Spring Boot --> 2.1.6.RELEASE spring-cloud-starter-openfeign --> 2.1.2.RELEASE feign-form-spring --> 3.3.0
I have following code in my Interface of Rest Controller Implementation
@PostMapping(value = "/files", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
ResponseEntity<Output> createFile(
@RequestPart("file") MultipartFile file,
@RequestPart("properties") Map<String, String> properties);
My Feign client just extends this interface and it has Feign Client Annotation like below
@FeignClient(name = "feign-client", url = "${host}/store/v1/", configuration = FeignConfig.class)
public interface StoreClient extends StoreInterface {
}
When I try to start my Spring Boot app, I get below exception
Caused by: java.lang.IllegalStateException: Method has too many Body parameters: public abstract org.springframework.http.ResponseEntity au.com.macquarie.bfs.ml.store.v1.StoreClient.createFile(org.springframework.web.multipart.MultipartFile,java.util.Map)
I tried googling and adopting many solutions, but looks like this is not supported yet.
Can some one help me resolve this and get around?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 21 (4 by maintainers)
Commits related to this issue
- Fix GH-201: Multiple @RequestPart not Working Summary of changes follows: - Delegate ALL requestBody encoding where Content-Type is multipart/form-data to the SpringFormEncoder. - Introduce RequestP... — committed to aaronjwhiteside/spring-cloud-openfeign by aaronjwhiteside 5 years ago
- Merge branch '2.2.x' into gh-201 — committed to aaronjwhiteside/spring-cloud-openfeign by aaronjwhiteside 4 years ago
- Fix GH-201: Multiple @RequestPart not Working Summary of changes follows: - Delegate ALL requestBody encoding where Content-Type is multipart/form-data to the SpringFormEncoder. - Introduce RequestP... — committed to aaronjwhiteside/spring-cloud-openfeign by deleted user 4 years ago
- Fix GH-201: Multiple @RequestPart not Working Summary of changes follows: - Delegate ALL requestBody encoding where Content-Type is multipart/form-data to the SpringFormEncoder. - Introduce RequestP... — committed to aaronjwhiteside/spring-cloud-openfeign by aaronjwhiteside 5 years ago
- Fix GH-201: Multiple @RequestPart not Working Summary of changes follows: - Delegate ALL requestBody encoding where Content-Type is multipart/form-data to the SpringFormEncoder. - Introduce RequestP... — committed to aaronjwhiteside/spring-cloud-openfeign by aaronjwhiteside 5 years ago
- Fix GH-201: Multiple @RequestPart not Working Summary of changes follows: - Delegate ALL requestBody encoding where Content-Type is multipart/form-data to the SpringFormEncoder. - Introduce RequestP... — committed to aaronjwhiteside/spring-cloud-openfeign by aaronjwhiteside 4 years ago
- Fix GH-201: Multiple @RequestPart not Working Summary of changes follows: - Delegate ALL requestBody encoding where Content-Type is multipart/form-data to the SpringFormEncoder. - Introduce RequestP... — committed to aaronjwhiteside/spring-cloud-openfeign by aaronjwhiteside 5 years ago
- Fix GH-201: Multiple @RequestPart not Working (#258) Summary of changes follows: - Delegate ALL requestBody encoding where Content-Type is multipart/form-data to the SpringFormEncoder. - Introduc... — committed to spring-cloud/spring-cloud-openfeign by aaronjwhiteside 4 years ago
- Add periodic-payments/pain.001-sepa-credit-transfers (multipart) support (#438) * Up spring-cloud version to fix feign error https://github.com/spring-cloud/spring-cloud-openfeign/issues/201 *... — committed to adorsys/xs2a-adapter by artemsnisarenko 4 years ago
I’m facing the same issue mentioned by @thekalinga and @mazkozi and would love to see a solution to this…
Actually I don’t see how it solves the issue exposed here (correct me if I’m wrong, but it doesn’t seem you are dealing with multiple @RequestPart).
works! If feign doesn’t sent POJO - just add bean JsonFormWriter in feign configuration:
Thanks @darrenfoong for the fix: https://github.com/spring-cloud/spring-cloud-openfeign/pull/314
@thekalinga @MrBogue
If you are still facing the problem, look to the Issue #62 . After reading the issue which provide a solution, I put another solution in the comments. You can directly see it here