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…
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…
I’ve used the java.net.HttpURLConnection for that.
There are plenty example to find if you search google on building HTTP GET/POST requests in Java.
I’d recommend that you use Retrofit 2 library, it is really simple but powerful : Retrofit — OAuth on Android
REST Service usage example:
public interface GitHubService {
@GET(“repos/{owner}/{repo}/contributors”)
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();