Sample code for 30+ languages & platforms
Swift

Send a REST Request with No Body

See more REST Examples

Demonstrates Rest.FullRequestNoBody, which sends a complete request with no request body (such as a GET or DELETE) and returns the response body as text.

Background. This is the simplest full-request convenience method, ideal for retrieval and deletion calls that carry no request payload.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let rest = CkoRest()!
    var bTls: Bool = true
    var bAutoReconnect: Bool = true
    success = rest.connect(hostname: "example.com", port: 443, tls: bTls, autoReconnect: bAutoReconnect)
    if success == false {
        print("\(rest.lastErrorText!)")
        return
    }

    //  Send a complete request with no request body, such as a GET or DELETE.  The response body is read
    //  as text and returned.
    var responseText: String? = rest.fullRequestNoBody(httpVerb: "GET", uriPath: "/api/items/123")
    if rest.lastMethodSuccess == false {
        print("\(rest.lastErrorText!)")
        return
    }

    print("\(responseText!)")

}