Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException: Method has too many Body parameters #793

Closed
shivamsingh opened this issue Sep 24, 2018 · 5 comments
Closed

IllegalStateException: Method has too many Body parameters #793

shivamsingh opened this issue Sep 24, 2018 · 5 comments
Labels
question General usage or 'how-to' questions spring-cloud Issues related to Spring Cloud OpenFeign

Comments

@shivamsingh
Copy link

shivamsingh commented Sep 24, 2018

Request method:

@RequestMapping(method = RequestMethod.POST, value = "/backend/tokenCheck")
    @Headers({HeaderConstants.REQUEST_ID + " {requestId}"})
    AuthResponseDto checkToken(AuthRequestDto authRequestDto, @Param("requestId") String requestId);

Can you please tell me how to use request body and dynamic headers at the same time?

Thanks a lot.

@shivamsingh
Copy link
Author

shivamsingh commented Sep 24, 2018

at feign.Util.checkState(Util.java:128) ~[feign-core-9.5.1.jar:na]
	at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:117) ~[feign-core-9.5.1.jar:na]
	at org.springframework.cloud.openfeign.support.SpringMvcContract.parseAndValidateMetadata(SpringMvcContract.java:133) ~[spring-cloud-openfeign-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
	at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:66) ~[feign-core-9.5.1.jar:na]
	at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:146) ~[feign-core-9.5.1.jar:na]
	at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:53) ~[feign-core-9.5.1.jar:na]
	at feign.Feign$Builder.target(Feign.java:218) ~[feign-core-9.5.1.jar:na]
	at org.springframework.cloud.openfeign.HystrixTargeter.target(HystrixTargeter.java:39) ~[spring-cloud-openfeign-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
	at org.springframework.cloud.openfeign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:261) ~[spring-cloud-openfeign-core-2.0.1.RELEASE.jar:2.0.1.RELEASE]
	at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:171) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]

@kdavisk6
Copy link
Member

A few things here you may want to double check.

First, you are mixing Feign and Spring annotations. I suggest @Param for @RequestParam, this is the most likely cause for that exception.

Next, annotation values must be literals. Your use of a constant in the @Headers will not work. The value will not be resolved and will result in the header not being constructed appropriately. An alternative way to accomplish this is to use the @RequestHeader annotation. Give those a try.

@kdavisk6 kdavisk6 added the question General usage or 'how-to' questions label Sep 24, 2018
@kdavisk6 kdavisk6 added the spring-cloud Issues related to Spring Cloud OpenFeign label Oct 10, 2018
@kdavisk6
Copy link
Member

@shivamsingh

Were you able to get this resolved?

@kdavisk6
Copy link
Member

I'm going to close this issue and recommend that questions like this be made on Stack Overflow, allowing more users to help you.

@jefferson-lima
Copy link

I had this issue because I was mixing Feign annotations with Spring annotations. In the particular case, I was using @HeadersMap, which I replaced with @RequestHeader to make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question General usage or 'how-to' questions spring-cloud Issues related to Spring Cloud OpenFeign
Projects
None yet
Development

No branches or pull requests

3 participants