Skip to content

Headers annotation not sending headers #983

Closed
@toadornode

Description

@toadornode

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");
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions