Sample code for 30+ languages & platforms
Rust

MedTunnel: Logout

See more MedTunnel Examples

Close the session for the logged in User.

Chilkat Rust Downloads

Rust

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

let http = chilkat::Http::new();

// 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.set_request_header("Authorization", "PutAuthorizationTokenHere");

let sb_response_body = chilkat::StringBuilder::new();
if http.quick_get_sb("https://server.medtunnel.com/MedTunnelSvc/api/Authenticate/Logout", &sb_response_body).is_err() {
    println!("{}", http.last_error_text());
    return;
}

let j_resp = chilkat::JsonObject::new();
let _ = j_resp.load_sb(&sb_response_body);
j_resp.set_emit_compact(false);

println!("Response Body:");
println!("{}", j_resp.emit().unwrap_or_default());

let resp_status_code = http.last_status();
println!("Response Status Code = {}", resp_status_code);
if resp_status_code >= 400 {
    println!("Response Header:");
    println!("{}", http.last_header());
    println!("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

let return_code = j_resp.int_of("ReturnCode");
let return_code_text = j_resp.string_of("ReturnCodeText").unwrap_or_default();
let data = j_resp.string_of("Data").unwrap_or_default();