3

I want to upload a file with Feign like this :

    @FeignClient(name = "GDC", url = "${gdc.url}", configuration = ApiConfig.class)
    public interface GDCClient {
        @RequestMapping(method = RequestMethod.POST, value = "/v1/document", consumes 
        ="multipart/form-data")
        Response saveDocument(@RequestPart(value = "file") MultipartFile fileSaveDocumentDTO, 
        @RequestPart(value = "document") SaveDocumentDTO saveDocumentDTO);
    }

But I have this error when I call saveDocument :

*java.lang.NoSuchFieldError: MULTIPART_RELATED
    at org.springframework.cloud.openfeign.support.SpringEncoder.isMultipartType(SpringEncoder.java:227) ~[spring-cloud-openfeign-core-2.2.8.RELEASE.jar:2.2.8.RELEASE]
    at org.springframework.cloud.openfeign.support.SpringEncoder.encode(SpringEncoder.java:102) ~[spring-cloud-openfeign-core-2.2.8.RELEASE.jar:2.2.8.RELEASE]
    at org.springframework.cloud.openfeign.support.PageableSpringEncoder.encode(PageableSpringEncoder.java:101) ~[spring-cloud-openfeign-core-2.2.8.RELEASE.jar:2.2.8.RELEASE]*

Someone can help me please ? :)

csalmhof
  • 1,820
  • 2
  • 15
  • 24
Anto
  • 31
  • 3

2 Answers2

0

OpenFeign dependency class org.springframework.cloud.openfeign.support.SpringEncoder contain constant MULTIPART_RELATED from org.springframework.http.MediaType. org.springframework.cloud:spring-cloud-starter-openfeign:2.2.8.RELEASE and version above contain this MULTIPART_RELATED in SpringEncoder-class. I'm using 2.2.7.RELEASE

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 03 '22 at 13:04
-1

Upgrade spring version at least 5.2.5