Sample code for 30+ languages & platforms
Rust

SugarCRM Logout

See more SugarCRM Examples

Demonstrates how to logout of a session.

Chilkat Rust Downloads

Rust

let rest = chilkat::Rest::new();

if rest.connect("your.site.domain", 443, true, true).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

let _ = rest.add_header("Cache-Control", "no-cache");
let _ = rest.add_header("OAuth-Token", "<access_token>");

let sb_req = chilkat::StringBuilder::new();

let sb_json = chilkat::StringBuilder::new();
if rest.full_request_sb("POST", "/rest/v10/oauth2/logout", &sb_req, &sb_json).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

if rest.response_status_code() != 200 {
    println!("Received error response code: {}", rest.response_status_code());
    println!("Response body:");
    println!("{}", sb_json.get_as_string().unwrap_or_default());
    return;
}

let json = chilkat::JsonObject::new();
let _ = json.load_sb(&sb_json);

// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.

let _ = json.bool_of("success");

// A sample JSON response body that is parsed by the above code:

// {
//   "success": true
// }

println!("Example Completed.");