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

Most upvoted comments

I’m facing the same issue mentioned by @thekalinga and @mazkozi and would love to see a solution to this…

@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

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:

import org.springframework.cloud.openfeign.support.AbstractFormWriter;
import org.springframework.cloud.openfeign.support.JsonFormWriter;
@Configuration
@ComponentScan
@EnableFeignClients
public class ClientConfiguration {
    @Bean
    public AbstractFormWriter jsonFormWriter() {
        return new JsonFormWriter();
    }
}

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