Sample code for 30+ languages & platforms
Swift

HTTP DELETE with Body

See more HTTP Examples

Demonstrates how to send a DELETE request with a body.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!

    // Use the HttpStr method (or HttpSb) to send a DELETE request with a body.
    var requestBody: String? = "{ \"abc\": 123 }"
    let resp = CkoHttpResponse()!
    success = http.httpStr(verb: "DELETE", url: "https://example.com/something", bodyStr: requestBody, charset: "utf-8", contentType: "application/json", response: resp)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

    print("Response status: \(resp.statusCode.intValue)")
    print("Response body: ")
    print("\(resp.bodyStr!)")

}