Java Requires Chilkat v11.0.0+
Chilkat2 Java
Example: Http.HttpNoBody method
Demonstrates how to use the HttpNoBody method to send HTTP requests without a request body (e.g., GET, DELETE, HEAD) and receive the response in a Chilkat Http response object.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpResponse;
public class ChilkatExample {
public static void main(String[] args) {
Http http = new Http();
HttpResponse resp = new HttpResponse();
// Send a DELETE request to https://api.example.com/users/123
String url = "https://api.example.com/users/123";
try {
http.httpNoBody("DELETE", url, resp);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
System.out.println("Response Status Code: " + resp.getStatusCode());
System.out.println("Response body:");
System.out.println(resp.getBodyStr());
}
}