Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

GroundWork RESTClient QuickStart

Patrick Bösch edited this page Nov 30, 2016 · 2 revisions

Dependency

maven

<dependency>
    <groupId>ch.viascom.groundwork</groupId>
    <artifactId>restclient-http</artifactId>
    <version>1.1-SNAPSHOT</version>
</dependency>

gradle

compile 'ch.viascom.groundwork:restclient-http:1.0-SNAPSHOT'

How to use

Get-Request with SimpleGetRequest

JSONResponse response = new SimpleGetRequest<>("https://jsonplaceholder.typicode.com/posts/1", JSONResponse.class).execute();
System.out.println(response.getResponseHeader());
System.out.println(response.toJson());

Get-Request with SimpleGetRequest (the long way)

String url = "https://jsonplaceholder.typicode.com";
String path = "/posts/1";

SimpleGetRequest<JSONResponse> request = new SimpleGetRequest<>(url, JSONResponse.class);
request.setPath(path);
JSONResponse response = request.execute();
System.out.println(response.getResponseHeader());
System.out.println(response.Json());