user4811324
user4811324

Reputation:

Call 3rd party api which is not part of project Eureka registry via Feign client

I need to invoke 3rd party api e.g.: https://google.com.systems.uk/some-api/.... (this is fake api but yes 3rd party service).

This api is not part of my microservices and is not registered on my eureka registry and I have not included any routing path for it in my gateway.

I need to invoke this api from my feign client but getting error

com.netflix.client.ClientException: Load balancer does not have available server for client:google.com.systems.uk

my feign client code:

@FeignClient(value = "https://google.com.systems.uk/some-api/",
        decode404 = true)
public interface DataFeign {
    @GetMapping("/query11")
    Object getData(@RequestHeader("Authorization") String someToken, @RequestBody Body queryBody);
}

Upvotes: 0

Views: 742

Answers (1)

user4811324
user4811324

Reputation:

I was able to figure out answer for it. use

@FeignClient(value = "Google" url = "https://google.com.systems.uk/some-api/",
        decode404 = true)
public interface DataFeign {
    @GetMapping("/query11")
    Object getData(@RequestHeader("Authorization") String someToken, @RequestBody Body queryBody);
}

url attribute of feign will help in invoking external api's. For calling api's of services registered with your registry you can use value or name attribute.

Upvotes: 1

Related Questions