-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
unable to add "literal" header values on template #1305
Comments
Your literal is in the format of an expression. To use this you must pct-encode the start and end braces using |
@kdavisk6 thanks very much for your kindly explanation. |
At the moment, you are correct. template.header("dummy", "{json}");
template.result(Map.of("dummy", "{\"A\":{\"B\":\"C\"}}")); This will produce the result you expect. Here is an example using the annotations: public interface Example {
@Request("/")
@Headers("X-JSON: {json}")
public void get(@Param("json") String json);
} |
In my situation, the value of header comes from theadlocal. It seem not suitable to pass in parameter. Is there a way to fill customized value to varBuilder in ReflectiveFeign.create(Object[]) which is used in RequestTemplate.resolve(Map<String, ?>) |
I tried this suggestion. It works great with version 10.7.0. I needed to upgrade my version of spring boot to 2.5.8 wich required spring-cloud-starter-openfeign version 3.1.0. This version embed feign core version 11.7 and my project doesnt work anymore. I did some test and with feign core version 11.0 my project works. With version 11.1 it doesnt work. |
Hi, Any news on this issue.
Is it possible to looke for a fix in latest version? thanks |
Hi,boy , |
This appears to be fixed in master at HEAD now but not yet released. I confirmed by writing a unit test for this case -- it passes. I checked out the last release and the unit test failed there. The fix for this is related to the fixes that came in for #1464 @kdavisk6 @velo I believe this can be closed once the next release goes out. I opened #1800 to cover this case with a test if you want it. |
I meet same problem, and I will show my resolution. copy file (HeaderTemplate and RequestTemplate) from new version of this commit to your project in same package position, it will overwrite the version of openfeign in jar. then change the HeaderTemplate's appendHeader() method to public. finally, to add header in this way: requestTemplate.appendHeader("someJson", "{\"name\":\"...+++AAA\"}", true); It's the only way I can find to resolve the problem but not upgrade feign version. If you have a better way, please tell me :) |
I am trying to use a feign.RequestInterceptor to add headers on the fly, these headers values are simple json. Example :
With version 10.7.4 I have got :
After seeing GH-1172 I had some hopes and tried with version 10.10.1, but got the same error.
I want to add "raw" headers values, no templated/parsed ones.
One simple solution would just to let this method public on RequestTemplate :
private RequestTemplate header(String name, TemplateChunk... chunks)
The text was updated successfully, but these errors were encountered: