<dependency> <groupId>org.kuali.client</groupId> <artifactId>kuali-http-client</artifactId> <version>1.0.0</version> </dependency> import org.kuali.client.HttpClient; import org.kuali.client.HttpResponse; public class HttpRequestExample { public static void main(String[] args) { HttpClient httpClient = new HttpClient(); HttpResponse response = httpClient.get("https://example.com/api/endpoint"); if (response.isSuccessful()) { String responseBody = response.getBody(); System.out.println("Response body: " + responseBody); } else { int statusCode = response.getStatusCode(); String errorMessage = response.getErrorMessage(); System.err.println("Request failed with status code: " + statusCode); System.err.println("Error message: " + errorMessage); } } } import org.kuali.client.HttpClient; import org.kuali.client.HttpResponse; public class HttpRequestExample { public static void main(String[] args) { HttpClient httpClient = new HttpClient(); httpClient.addHeader("Authorization", "Bearer your-token"); httpClient.addParam("page", "1"); httpClient.addParam("limit", "10"); HttpResponse response = httpClient.get("https://example.com/api/endpoint"); } }


上一篇:
下一篇:
切换中文