Sample code for 30+ languages & platforms
Rust

Zendesk List Users

See more Zendesk Examples

List users.

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 https://{subdomain}.zendesk.com/api/v2/users.json
//    -u {email_address}:{password_or_api_token}

// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code

http.set_basic_auth(true);
// To authenticate using your email address + password, do this:
http.set_login("joe@example.com");
http.set_password("your_password");

// Alternatively, to authenticate using your email address + API token, do this:
// (The login is the concatenation of your email address with the string "/token".  For example: "joe@somewhere.com/token")
http.set_login("joe@example.com/token");
http.set_password("your_api_token");

// Chilkat's subdomain is "chilkatsoft".  You will change "chilkatsoft" to use your subdomain.
let sb_response_body = chilkat::StringBuilder::new();
if http.quick_get_sb("https://chilkatsoft.zendesk.com/api/v2/users.json", &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:

// Use this online tool to generate parsing code from sample JSON: 
// Generate Parsing Code from JSON