The solution is to use @RequestHeader annotation instead of feign specific annotations
@FeignClient(name="Simple-Gateway")
interface GatewayClient {
@RequestMapping(method = RequestMethod.GET, value = "/gateway/test")
String getSessionId(@RequestHeader("X-Auth-Token") String token);
}
Answer from Hasnain on Stack OverflowBaeldung
baeldung.com › home › rest › setting request headers using feign
Setting Request Headers Using Feign | Baeldung
March 25, 2026 - Feign allows us to build HTTP clients simply with a declarative syntax. In this short tutorial, we’ll see how to configure the request headers using annotations. We’ll also see how to include common request headers by using interceptors. Throughout this tutorial, we’ll be using an example Bookstore Application that exposes REST API endpoints.
Medium
medium.com › @mtl98 › sending-headers-in-feign-client-94096c9069e6
Sending Headers in Feign Client | by Mohammed Taoufik Lahmidi | Medium
December 13, 2024 - The @RequestHeader annotation is straightforward and convenient for adding headers to specific methods in your Feign client. Here's how you can use it: First, create an interface and annotate it with @FeignClient. This tells Spring to create a bean for this interface and handle the communication. import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestHeader; @FeignClient(name = "example-client", url = "http://example.com") public interface ExampleClient { @GetMapping("/api/v1/resource") String getResourceV1(@RequestHeader("Custom-Header") String headerValue); @GetMapping("/api/v2/resource") String getResourceV2(@RequestHeader Map<String,String> headerValues); }
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
Top answer 1 of 7
124
The solution is to use @RequestHeader annotation instead of feign specific annotations
@FeignClient(name="Simple-Gateway")
interface GatewayClient {
@RequestMapping(method = RequestMethod.GET, value = "/gateway/test")
String getSessionId(@RequestHeader("X-Auth-Token") String token);
}
2 of 7
29
The @RequestHeader did not work for me. What did work was:
@Headers("X-Auth-Token: {access_token}")
@RequestLine("GET /orders/{id}")
Order get(@Param("id") String id, @Param("access_token") String accessToken);
Arnoldgalovics
arnoldgalovics.com › spring-cloud-feign-headers
Passing headers with Spring Cloud Feign – Arnold Galovics
The important thing here is that the controller method accepts a parameter which is coming from the Accept-Language HTTP header which we will pass with the Feign client on the app side.
Fullstackdeveloper
fullstackdeveloper.guru › 2020 › 05 › 15 › how-to-send-multiple-headers-using-open-feign
How to send multiple headers using Open Feign ? – The Full Stack Developer
March 24, 2021 - package com.springboot.openfeign; import java.util.List; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @FeignClient(name = "personclient", url = "http://localhost:8090/") public interface PersonClient { @RequestMapping(method = RequestMethod.GET, value = "/persons") List<Person> getPersons(@RequestHeader("Authorization") String header, @RequestHeader("color-of-my-bike") String bikeColor); }
GitHub
github.com › OpenFeign › feign › issues › 363
Support setting headers per request with parameters from map · Issue #363 · OpenFeign/feign
March 20, 2016 - @RequestLine("POST /") @Headers({"Auth-Token: {authToken}", "Auth-Token: Foo"}) void logout(@Param("authToken") String token, @HeaderMap Map<String, Object> headers); In this example, any calls will expand the content of headers and add it (or override if keys are identical) to the headers ...
Author: OpenFeign
Javadoc.io
javadoc.io › static › io.github.openfeign › feign-core › 11.1 › feign › Headers.html
Headers (Feign Core 11.1 API)
@Headers("Content-Type: application/xml") interface SoapApi { ... @RequestLine("GET /") @Headers("Cache-Control: max-age=640000") ... @RequestLine("POST /") @Headers({ "X-Foo: Bar", "X-Ping: {token}" }) void post(@Param("token") String token); ...
Javadoc.io
javadoc.io › static › com.netflix.feign › feign-core › 6.0.1 › feign › Headers.html
Headers (feign-core 6.0.1 API)
@RequestLine("GET /") @Headers("Cache-Control: max-age=640000") ... @RequestLine("POST /") @Headers({ "X-Foo: Bar", "X-Ping: {token}" }) void post(@Named("token") String token); ... Note: Headers do not overwrite each other. All headers with the same name will be included in the request.
Arnoldgalovics
arnoldgalovics.com › feign-interceptor
Customizing each request with Spring Cloud Feign interceptor – Arnold Galovics
February 19, 2018 - Feign has a so called RequestInterceptor which will be applied for all the requests sent by Feign clients. The only thing that’s necessary is to define a custom RequestInterceptor class and register it as a Spring bean. Let’s see how it looks: @Component public class LanguageRequestInterceptor implements RequestInterceptor { private static final String ACCEPT_LANGUAGE_HEADER = "Accept-Language"; @Override public void apply(RequestTemplate requestTemplate) { ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); if (requestAttributes == null) { return; } HttpServletRequest request = requestAttributes.getRequest(); if (request == null) { return; } String language = request.getHeader(ACCEPT_LANGUAGE_HEADER); if (language == null) { return; } requestTemplate.header(ACCEPT_LANGUAGE_HEADER, language); } }
GitConnected
levelup.gitconnected.com › feign-client-query-parameters-and-headers-08677ed260b1
Feign client Query Parameters and Headers | by Ivan Polovyi | Level Up Coding
April 4, 2025 - Feign client Query Parameters and Headers This tutorial will provide explanations with examples of how to use query parameters and headers in a Feign client. This friendly link is for those without a …
CodingTechRoom
codingtechroom.com › tutorial › java-understanding-feign-client-request-headers-in-java
Java Feign Request Headers: A Comprehensive Guide - CodingTechRoom
A. Use a combination of `@Headers` for static headers and request interceptors for dynamic headers. Q. Can I use Feign with Spring Boot?
Spring
docs.spring.io › spring-cloud-openfeign › docs › current › reference › html
Spring Cloud OpenFeign
The Logger.Level object that you may configure per client, tells Feign how much to log. Choices are: NONE, No logging (DEFAULT). BASIC, Log only the request method and URL and the response status code and execution time. HEADERS, Log the basic information along with request and response headers. FULL, Log the headers, body, and metadata for both requests and responses. For example, the following would set the Logger.Level to FULL:
Top answer 1 of 2
7
Custom decoder
You could use a custom decoder:
public class CustomDecoder extends GsonDecoder {
private Map<String, Collection<String>> headers;
@Override
public Object decode(Response response, Type type) throws IOException {
headers = response.headers();
return super.decode(response, type);
}
public Map<String, Collection<String>> getHeaders() {
return headers;
}
}
Return Response
Other solution could be return Response instead of List<Dto>:
@Headers({
"Content-Type: " + MediaType.APPLICATION_JSON_UTF8_VALUE
})
@RequestLine("GET Dto/")
Response search();
Then deserialize body and get headers:
Response response = Client.search();
response.headers();
Gson gson = new Gson();
gson.fromJson(response.body().asReader(), Dto.class);
2 of 2
6
I'm getting late to the party, but I know for someone in the future it could help
We can wrap our response into a ResponseEntity<SomePojo>, by doing that we can access as the headers object as the body with type SomePojo.
...
import org.springframework.http.ResponseEntity;
...
public ResponseEntity<List<Dto>> search() {
DtoClient client = DtoClient.connect();
return client.search();
}
Javahowtos
javahowtos.com › demo slot › slot demo gacor › slot gacor
Simulasi Real-Time Demo Gacor: Rasakan Sensasi Maxwin X1000 dengan Akun Demo PG Soft & Pragmatic Play Terbaru 2026
DEMO SLOT - Coba Demo Slot Gratis terbaru 2026 tanpa deposit. Pelajari setiap fitur Pragmatic Play dan PG Soft. Manfaatkan simulasi real-time anti lag untuk menguji strategi dan temukan kunci rahasia Maxwin X1000.
Price: IDR 97,962
Codeboje
codeboje.de › getting-started-feignclient
Getting Started with Feign Client in Spring - codeboje
January 15, 2020 - We can always pass down authentication headers using the @RequestHeader annotation on each method. However, there is also an alternative way to specify that globally. Like Spring MVC, Feign has an interceptor concept, which can be used to do specific stuff before a remote call.