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 - 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.
🌐
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.
🌐
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. On the app side, I have the Feign client in the following way: @FeignClient(name = "translation", url = "http://localhost:9001") public interface TranslationClient { @RequestMapping("/message") MessageResponse message(@RequestHeader("Accept-Language") String language); } As you can see, I used the very same Spring MVC annotation for passing the language header.
🌐
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.
🌐
Medium
medium.com › @AlexanderObregon › how-spring-boot-implements-feign-clients-for-rest-apis-8a4108fa248c
How Spring Boot Implements Feign Clients for REST APIs
January 27, 2025 - Spring Boot configures Feign to ... and features. ... Feign converting the RequestTemplate into a format that the HTTP client can use, including headers, query strings, and serialized body content....
🌐
Javatodev
javatodev.com › how-to-use-feign-client-in-spring-boot
How to Use Feign Client in Spring Boot
October 3, 2020 - We can achieve this using feign.RequestInterceptor. Basically, this adds header values to every and each request going through the feign client in Spring boot.
🌐
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.
🌐
GitHub
github.com › PouyaPouryaie › feign-client
GitHub - PouyaPouryaie/feign-client: This repository demonstrates how to programmatically implement a Feign client in a Spring Boot application · GitHub
This class implements RequestInterceptor to add a custom header (X-Custom-Header: CustomValue) to every outgoing request made by the Feign client to the server. // client/src/main/java/ir/bigz/spring/client/feignclient/FeignClientHeaderRequ...
Find elsewhere
Top answer
1 of 3
7

Yes, you can do that. With Feign, we usually declare our interface with the method returning our class and Feign will automatically de-serialise the response from JSON into our POJO.

Here is the interface (operation):

@FeignClient(name = "library-book-service")
@RequestMapping("books")
public interface BookClient {

    @GetMapping
    public List<Book> getBooks(
        @RequestParam("page") Integer pageNum,
        @RequestParam("size") Integer pageSize,
        @RequestParam("reader") Long readerId);
}

And then you can use the feign client like this:

@Service
@RequiredArgsConstructor
public class BookService {
    private final @NonNull BookClient bookClient;

    public List<Book> retrieveBooks(
        Integer pageNum, 
        Integer pageSize, 
        Long readerId) {

            return bookClient.getBooks(pageNum, pageSize, readerId);
    }

However, in order to have access to the response headers, you need to declare your methods to return feign.Response.

import feign.Response;

@FeignClient(name = "library-book-service")
@RequestMapping("books")
public interface BookClient {

    @GetMapping
    public Response getBooks(
        @RequestParam("page") Integer pageNum,
        @RequestParam("size") Integer pageSize,
        @RequestParam("reader") Long readerId);
}

This way you can have access to the response body and headers:

@Service
@RequiredArgsConstructor
public class BookService {
    private final @NonNull BookClient bookClient;
    private final @NonNull ObjectMapper objectMapper;

    public List<Book> retrieveBooks(
        Integer pageNum, 
        Integer pageSize, 
        Long readerId) {

          var response = bookClient.getBooks(pageNum, pageSize, readerId);
          if (response == null) {
            return Collections.emptyList();
          }

          // retrieve body
          var books = objectMapper.readValue(
            new BufferedReader(new InputStreamReader(response.body().asInputStream(), StandardCharsets.UTF_8)),
            new TypeReference<List<Book>>(){});

          // retrieve headers
          Map<String, Collection<String>> headers = response.headers();
          // ... do whatever you need with the headers

          return books;
    }
2 of 3
2

You can use import feign.Response as a response like:

@PostMapping("/test")
Response test(@RequestBody TestRequest testRequest);

then you can reach http header

response.headers().get(HEADER_NAME).toString();

if you want get body in this case you have to some json-string manipulation by use response.body() this page may help you for this

🌐
Medium
medium.com › @mtl98 › sending-headers-in-feign-client-94096c9069e6
Sending Headers in Feign Client | by Mohammed Taoufik Lahmidi | Medium
December 13, 2024 - 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); }
🌐
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 - public interface WeirdClient { @RequestLine("GET /test") @Headers({"test: someVal"}) String getStuff(); } @Configuration public class FeignClientConfig { @Bean public WeirdClient weirdClient() { return Feign.builder() .target(WeirdClient.class, "http://localhost:8080"); } }
Author: spring-cloud
🌐
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
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)
    }
}
🌐
TheCodeForge
thecodeforge.io › home › java › spring cloud feign client: declarative http in microservices
Feign Client in Spring Boot Microservices: Spring Cloud | TheCodeForge
May 23, 2026 - RequestInterceptor is the canonical pattern for cross-cutting headers (auth tokens, correlation IDs) across all Feign calls from a client ... Multiple @FeignClient interfaces targeting the same service must use contextId to avoid Spring bean definition conflicts
🌐
GitHub
github.com › OpenFeign › feign
GitHub - OpenFeign/feign: Feign makes writing java http clients easier · GitHub
Defines a Template, similar to a UriTemplate and HeaderTemplate, that uses @Param annotated values to resolve the corresponding Expressions. ... If there is a need to target a request to a different host then the one supplied when the Feign ...
Author: OpenFeign
🌐
Baeldung
baeldung.com › home › spring › spring cloud › introduction to spring cloud openfeign
Introduction to Spring Cloud OpenFeign | Baeldung
February 19, 2026 - Feign supports multiple clients for different use cases, including the ApacheHttpClient, which sends more headers with the request, for example, Content-Length, which some servers expect.