Feign: OpenFeign Client HTTP.GET: Method has too many Body parameters

Created on 17 Feb 2020  路  3Comments  路  Source: OpenFeign/feign

This works:

//Example 1 @Headers("Content-Type: application/json") @RequestLine("POST api/v2/clients") ClientResponse findAllClientsByUid1(@RequestBody ClientRequest request);

But this doesn't work:

//Example 2 @Headers("Content-Type: application/json") @RequestLine("GET api/v2/clients/{uid}") ClientResponse findAllClientsByUid2(@PathVariable(value = "uid") String uid, @RequestParam(value = "limit", required = false) Integer limit, @RequestParam(value = "offset", required = false) Integer offset); }

Caused by: java.lang.IllegalStateException: Method has too many Body parameters: public abstract com.services.requestresponse.ClientResponse com.microservice.gateway.feign.ClientFeignV2.findAllClientsByUid2(java.lang.String,java.lang.Integer,java.lang.Integer)

Based on the exception, it's failing because the HTTP.GET method doesn't allow response objects to have too many fields & nested fields. Surprisingly using the same returned Response Objects for the HTTP.POST, it works well. But According to REST-API standards, I can't do a POST when I want to read a resource.

Most helpful comment

This is a consequence of mixing feign and jaxrs annotations.

Either use feign contract or jaxrs contract.

All 3 comments

This is a consequence of mixing feign and jaxrs annotations.

Either use feign contract or jaxrs contract.

Made a PR to add more information when this happens

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdancy picture cdancy  路  6Comments

tjuchniewicz picture tjuchniewicz  路  5Comments

rhudson picture rhudson  路  7Comments

JerryChaox picture JerryChaox  路  3Comments

fmarot picture fmarot  路  3Comments