Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headers annotation not sending headers #983

Closed
toadornode opened this issue Feb 11, 2024 · 4 comments
Closed

Headers annotation not sending headers #983

toadornode opened this issue Feb 11, 2024 · 4 comments
Assignees
Milestone

Comments

@toadornode
Copy link

toadornode commented Feb 11, 2024

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");
    }
}
@toadornode
Copy link
Author

toadornode commented Feb 11, 2024

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/

@OlgaMaciaszek
Copy link
Collaborator

Hello @toadornode, yes, we do not recommend mixing the Spring Cloud OpenFeign and native Feign annotations on one method.

@OlgaMaciaszek OlgaMaciaszek added question Further information is requested and removed waiting-for-triage labels Feb 16, 2024
@OlgaMaciaszek OlgaMaciaszek self-assigned this Feb 16, 2024
@si-net
Copy link

si-net commented Nov 11, 2024

@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.

@OlgaMaciaszek
Copy link
Collaborator

Will do.

@OlgaMaciaszek OlgaMaciaszek reopened this Nov 12, 2024
@OlgaMaciaszek OlgaMaciaszek added documentation and removed question Further information is requested labels Nov 12, 2024
@OlgaMaciaszek OlgaMaciaszek added this to the 4.1.4 milestone Nov 12, 2024
@OlgaMaciaszek OlgaMaciaszek moved this to In Progress in 2023.0.4 Nov 12, 2024
@spencergibb spencergibb moved this to In Progress in 2024.0.0 Nov 12, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in 2023.0.4 Nov 12, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in 2024.0.0 Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Status: Done
Development

No branches or pull requests

4 participants