I was facing an issue that my GET requests were being changed to POST due the RequestHeader and PathVariable that were being interpreted as body of the request in Feign Client.
Interceptor
public class OpenFeignConfiguration implements RequestInterceptor {
@Value("${key:}")
private String key;
@Bean
Logger.Level feignLoggerLevel() {
return Logger.Level.FULL;
}
@Override
public void apply(RequestTemplate template) {
template.header("key", key);
}
}
And the Feign Client
@FeignClient(name = "feignClient", url = "${client.url}", configuration = OpenFeignConfiguration.class)
public interface FeignClient {
@GetMapping(value = "/path/?test=({var1} and {var2})")
public Object test(String body, @PathVariable("var1") String var1, @PathVariable("var2") String var2);
}