Rust
Rust
List all Labels in the User's Mailbox
See more GMail REST API Examples
List all Labels in the GMail User's MailboxChilkat Rust Downloads
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
http.set_auth_token("GMAIL-ACCESS-TOKEN");
let user_id = "me".to_string();
let _ = http.set_url_var("userId", &user_id);
let url = "https://www.googleapis.com/gmail/v1/users/{$userId}/labels".to_string();
http.set_session_log_filename("c:/temp/qa_output/sessionLog.txt");
// Get the list of GMail labels as JSON.
let sb = chilkat::StringBuilder::new();
if http.quick_get_sb(&url, &sb).is_err() {
println!("{}", http.last_error_text());
return;
}
let json = chilkat::JsonObject::new();
let _ = json.load_sb(&sb);
json.set_emit_compact(false);
println!("{}", json.emit().unwrap_or_default());
if http.last_status() != 200 {
println!("Failed.");
return;
}