<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.example.com/users")
.header("Authorization", "Bearer token")
.queryString("page", 1)
.asString();
String responseBody = response.getBody();
int statusCode = response.getStatus();
HttpResponse<String> response = Unirest.post("https://api.example.com/users")
.header("Authorization", "Bearer token")
.header("Content-Type", "application/json")
.body("{\"name\": \"John\", \"email\": \"john@example.com\"}")
.asString();
String responseBody = response.getBody();
int statusCode = response.getStatus();
HttpResponse<String> response = Unirest.put("https://api.example.com/users/1")
.header("Authorization", "Bearer token")
.header("Content-Type", "application/json")
.body("{\"name\": \"Updated Name\", \"email\": \"updated@example.com\"}")
.asString();
String responseBody = response.getBody();
int statusCode = response.getStatus();
HttpResponse<String> response = Unirest.delete("https://api.example.com/users/1")
.header("Authorization", "Bearer token")
.asString();
String responseBody = response.getBody();
int statusCode = response.getStatus();