Sample code for 30+ languages & platforms
Java

HTTP DELETE with Body

See more HTTP Examples

Demonstrates how to send a DELETE request with a body.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpResponse;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example assumes the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Http http = new Http();

        // Use the HttpStr method (or HttpSb) to send a DELETE request with a body.
        String requestBody = "{ \"abc\": 123 }";
        HttpResponse resp = new HttpResponse();
        try {
            http.httpStr("DELETE", "https://example.com/something", requestBody, "utf-8", "application/json", resp);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        System.out.println("Response status: " + resp.getStatusCode());
        System.out.println("Response body: ");
        System.out.println(resp.getBodyStr());
    }
}