How to consume an Api Rest from a controller in Spring boot?

-2

Good morning,

I would need an example made with springRestTemplate / retrofit to be able to consume from a controller of a service own data provided by an external api rest.

That is, I expose a service which queries data from an external api processes them and returns it.

Thank you very much.

    
asked by Gonzalo Zago 05.12.2017 в 16:56
source

1 answer

0

You can try this example is simple but it is a guide so that it will help you to be other things.

Interface

public interface GitHubService {
@GET("/users/{user}/repos")
List listRepos(@Path("user") 
String user); 
}

the call to the service

RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint("https://api.github.com")
.build();

GitHubService service = restAdapter.create(GitHubService.class);

List repos = service.listRepos("octocat");
    
answered by 19.12.2017 в 16:04