Swift
Swift
MedTunnel: Logout
See more MedTunnel Examples
Close the session for the logged in User.Chilkat Swift Downloads
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()!
// Implements the following CURL command:
// curl -X GET -k
// -H "Authorization:PutAuthorizationTokenHere"
// https://server.medtunnel.com/MedTunnelSvc/api/Authenticate/Logout
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
http.setRequestHeader(name: "Authorization", value: "PutAuthorizationTokenHere")
let sbResponseBody = CkoStringBuilder()!
success = http.quickGetSb(url: "https://server.medtunnel.com/MedTunnelSvc/api/Authenticate/Logout", sbContent: sbResponseBody)
if success == false {
print("\(http.lastErrorText!)")
return
}
let jResp = CkoJsonObject()!
jResp.loadSb(sb: sbResponseBody)
jResp.emitCompact = false
print("Response Body:")
print("\(jResp.emit()!)")
var respStatusCode: Int = http.lastStatus.intValue
print("Response Status Code = \(respStatusCode)")
if respStatusCode >= 400 {
print("Response Header:")
print("\(http.lastHeader!)")
print("Failed.")
return
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "ReturnCode": 1,
// "ReturnCodeText": "Success",
// "Data": "1"
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
var ReturnCode: Int = jResp.int(of: "ReturnCode").intValue
var ReturnCodeText: String? = jResp.string(of: "ReturnCodeText")
var Data: String? = jResp.string(of: "Data")
}