Calling REST QUERY from Service method / java class

Hi Team,

I want to call a rest query from java method .

What is the syntax or format for calling the REST QUERY?
Any sample code…Please…

1 Like

I’ve used the for that.

There are plenty example to find if you search google on building HTTP GET/POST requests in Java.

1 Like

I’d recommend that you use Retrofit 2 library, it is really simple but powerful :

REST Service usage example:

public interface GitHubService {
  Call<List<Contributor>> repoContributors(
      @Path(“owner”) String owner,
      @Path(“repo”) String repo);

GitHubService gitHubService = GitHubService.retrofit.create(GitHubService.class);
Call<List<Contributor>> call = gitHubService.repoContributors(“square”, “retrofit”);
List<Contributor> result = call.execute().body();