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.
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]
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.
@shivamsingh
Were you able to get this resolved?
I'm going to close this issue and recommend that questions like this be made on Stack Overflow, allowing more users to help you.
Most helpful comment
A few things here you may want to double check.
First, you are mixing Feign and Spring annotations. I suggest
@Paramfor@RequestParam, this is the most likely cause for that exception.Next, annotation values must be literals. Your use of a constant in the
@Headerswill 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@RequestHeaderannotation. Give those a try.