Sample code for 30+ languages & platforms
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

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    CkHttp http = new CkHttp();
    CkHttpResponse resp = new CkHttpResponse();

    //  Send a DELETE request to https://api.example.com/users/123
    String url = "https://api.example.com/users/123";
    success = http.HttpNoBody("DELETE",url,resp);
    if (success == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println("Response Status Code: " + resp.get_StatusCode());
    System.out.println("Response body:");
    System.out.println(resp.bodyStr());
  }
}