import kong.unirest.Unirest; public class UseUnirest { public static void get() { String url = "https://jsonplaceholder.typicode.com/users"; String res = Unirest.get(url).asString().getBody(); System.out.println(res); } public static void post() { String url = "https://jsonplaceholder.typicode.com/users"; String body = "{ \"name\": \"John\", \"age\": 30 }"; String res = Unirest.post(url) .header("Content-Type", "application/json") .body(body) .asString() .getBody(); System.out.println(res); } public static void put() { String url = "https://jsonplaceholder.typicode.com/users/1"; String body = "{ \"name\": \"John\", \"age\": 30 }"; String res = Unirest.put(url) .header("Content-Type", "application/json") .body(body).asString().getBody(); System.out.println(res); } public static void delete() { String url = "https://jsonplaceholder.typicode.com/users/1"; String res = Unirest.delete(url).asString().getBody(); System.out.println(res); } }