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 Overflow
🌐
Baeldung
baeldung.com › home › rest › setting request headers using feign
Setting Request Headers Using Feign | Baeldung
March 25, 2026 - OpenFeign is a library that helps us build clients to web services by expressing the contract in a Java interface. We look at how to include header values in our requests through the interface, with fixed and dynamic values, and how to handle ...
🌐
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.
🌐
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.
🌐
Medium
medium.com › @jrcdsf › injecting-url-and-headers-dynamically-at-feign-client-9f63eb612367
Injecting URL and Headers dynamically at Feign Client | by José Roberto Costa | Medium
June 22, 2022 - 8. Create a service and inject the Feign client into it. You should pass the URL and the headers into the method execute():
🌐
GitHub
github.com › OpenFeign › feign
GitHub - OpenFeign/feign: Feign makes writing java http clients easier · GitHub
If not, the Content-Length header will not be added. In many cases, apis for a service follow the same conventions. Feign supports this pattern via single-inheritance interfaces.
Author: OpenFeign
Top answer
1 of 2
11

You can create an interceptor that'd inject headers in all requests as below:

@Bean
public RequestInterceptor requestInterceptor() {
  return requestTemplate -> {
      requestTemplate.header("user", username);
      requestTemplate.header("password", password);
      requestTemplate.header("Accept", ContentType.APPLICATION_JSON.getMimeType());
  };
}

Also it provides a way to set interceptor using property files as below:

feign:
  client:
    config:
      default:
        requestInterceptors:
          com.baeldung.cloud.openfeign.JSONPlaceHolderInterceptor

we can create the configuration with default as the client name to configure all @FeignClient objects, or we can declare the feign client name for a configuration

Reference: https://www.baeldung.com/spring-cloud-openfeign

EDIT: Another way is to set headers in yml as below:

feign:
  client:
    config:
      default:
        defaultRequestHeaders:
          Authorization:
            - Basic dXNlcjpwYXNzd29yZA==
          SomeOtherHeader:
            - Value1
            - Value2
2 of 2
2

we have used below for kotlin to make sure we add proper headers to all the request sent :

Feign client with configuration setup

@FeignClient(name = "YourClient", url = "\${base-url}", configuration = [FeignHeaderConfiguration::class])
interface YourClient 

Header configuration

@Configuration
class FeignHeaderConfiguration {

    @Bean
    fun clientHeaderInterceptor(): ClientHeaderInterceptor {
        return ClientHeaderInterceptor()
    }
}

and interceptor where we added the header

class ClientHeaderInterceptor : RequestInterceptor {
    override fun apply(requestTemplate: RequestTemplate) {
       requestTemplate.header("Accept", MediaType.APPLICATION_JSON_VALUE)
    }
}
🌐
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.
🌐
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 …
Find elsewhere
🌐
GitHub
github.com › spring-cloud › spring-cloud-openfeign › issues › 889
Provide a way to specify static headers per request basis
August 31, 2023 - This header will not change from invocation to invocation, so we do not want to go for @RequestHeader. We also do not want to create a RequetsInterceptor, since in this case it will be applied for entier feign client, but the requestFile() or any other method that we have in this method in reality - we do not want Content-Type: multipart/form-data header to be in the request for obvious reasons.
Author: spring-cloud
🌐
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.
🌐
GitHub
github.com › spring-cloud › spring-cloud-netflix › issues › 1360
Support sending multiple headers or query parameters to Feign client without knowing names · Issue #1360 · spring-cloud/spring-cloud-netflix
September 23, 2016 - Since Feign requires all headers to be explicitly specified, this is currently not possible. It'd be nice to be able to just send a ? extends Map<String, ? extends List<String>> to Feign and have it add all the entries to the request.
Author: spring-cloud
🌐
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.
🌐
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.
(5.0)
Price: IDR 97,962
🌐
GitHub
github.com › spring-cloud › spring-cloud-openfeign › issues › 983
Headers annotation not sending headers · Issue #983 · spring-cloud/spring-cloud-openfeign
February 11, 2024 - @FeignClient(name = "WeirdClient", url="http://localhost:8080") public interface WeirdClient { @RequestMapping(method = RequestMethod.GET, value = "/test", consumes="application/json") @Headers({"test: someVal"}) String getStuff(); }
Author: spring-cloud
🌐
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. Relationship to JAXRS The following two forms are identical. Feign:
🌐
DEV Community
dev.to › tarcalia › feign-clients-with-multiple-interceptors-in-spring-boot-hh2
Feign Clients with Multiple Interceptors in Spring Boot - DEV Community
June 18, 2025 - Make sure your application is configured to scan for Feign clients: @EnableFeignClients @SpringBootApplication public class App { public static void main(String[] args) { SpringApplication.run(App.class, args); } } When your application makes a call via the FooClient, all configured interceptors will be applied and headers added to the request.