(Java) HTTP DELETE with Body
Demonstrates how to send a DELETE request with a body.
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[])
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http = new CkHttp();
// Use the PText method (or PTextSb) to send a DELETE request with a body.
String requestBody = "{ \"abc\": 123 }";
CkHttpResponse resp = http.PText("DELETE","https://example.com/something",requestBody,"utf-8","application/json",false,false);
if (http.get_LastMethodSuccess() == false) {
System.out.println(http.lastErrorText());
return;
}
System.out.println("Response status: " + resp.get_StatusCode());
System.out.println("Response body: ");
System.out.println(resp.bodyStr());
}
}
|