Maven:
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
Gradle:
groovy
implementation 'com.mashape.unirest:unirest-java:1.4.9'
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
public class HttpClientExample {
public static void main(String[] args) {
try {
HttpResponse<JsonNode> jsonResponse = Unirest.get("http://api.example.com/users")
.queryString("name", "John Doe")
.asJson();
int status = jsonResponse.getStatus();
JsonNode body = jsonResponse.getBody();
System.out.println("Status: " + status);
System.out.println("Body: " + body);
} catch (UnirestException e) {
e.printStackTrace();
}
}
}