I'm not sure what I'm doing wrong here.
I've included spring cloud open feign dependency
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:4.1.0'
Then in my feign client interface
@FeignClient(name = "WeirdClient", url="http://localhost:8080")
public interface WeirdClient {
@RequestMapping(method = RequestMethod.GET, value = "/test", consumes="application/json")
@Headers({"test: someVal"})
String getStuff();
}
Yet, the header does not get sent.
If I make the implementation like the following then it gets sent
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");
}
}
Comment From: toadornode
Okay, I figured out the issue... You have to use the built in headers as part of the RequestMapping.
@RequestMapping(method = RequestMethod.GET, value = "/test", consumes="application/json",
headers = "test=someVal")
I guess I was referencing a different Feign Client implementation... kind of confusing https://www.baeldung.com/intro-to-feign
It might be worth adding a header example in the documentation: https://cloud.spring.io/spring-cloud-openfeign/reference/html/
Comment From: OlgaMaciaszek
Hello @toadornode, yes, we do not recommend mixing the Spring Cloud OpenFeign and native Feign annotations on one method.
Comment From: si-net
@OlgaMaciaszek I would recommend that you explicitly document this then.
Right now you are referencing feign documentation in a lot of places, when in fact the feign documentation is just incompatible with this project.
Comment From: OlgaMaciaszek
Will do.