Search code examples
spring-cloud-netflixfeignnetflix

Method has too many Body parameters


I have the following requestMethod in a RestController class and it´s working fine:

@RequestMapping(path = "/api/v1/rest/websearcher/search/results", method = RequestMethod.POST,
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResponseEntity<WebResultResponse> getSavedAvailability(@RequestBody final WebResultRequest navigationRequest, 
    @CookieValue(value = "forceSupplier", defaultValue = "") final String forceSupplier)

I´ve also a feign client working fine as well. I added a new parameter called forceSupplier in both methods, but after adding it, I´m having the issue Method has too many Body parameters but I don´t really understand why I´m receiving this message because the param is the same.

This is the method in Feign:

@RequestMapping(path = "/api/v1/rest/websearcher/search/results", method = RequestMethod.POST,
        produces = MediaType.APPLICATION_JSON_VALUE + ";charset=UTF-8")
ResponseEntity<WebResultResponse> getAndSavedAvailability(
@RequestBody WebResultRequest webSearcherResultRequest,
@CookieValue(value = "forceSupplier", defaultValue = "") String forceSupplier);

What am I doing wrong? Thanks


Solution

  • The annotation @CookieValue is not supported when using Spring Cloud OpenFeign. As a result, Feign sees your @RequestBody and @CookieValue parameters as the request entities, and since you only have one request entity, Feign throws the exception you are seeing.

    There is currently no support for Cookies in Feign.