Sample code for 30+ languages & platforms
Rust

Add Multiple Query Parameters from a Query String

See more REST Examples

Demonstrates Rest.AddQueryParams, which adds several query parameters at once from a query-string in the form field1=value1&field2=value2.

Background. This is a convenient shortcut for populating many parameters from a single pre-built query string rather than calling AddQueryParam repeatedly.

Chilkat Rust Downloads

Rust

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

// Connect to the REST server.  The 3rd argument enables TLS (use true for HTTPS on port 443),
// and the 4th enables automatic reconnection if the connection is dropped between requests.
let b_tls = true;
let b_auto_reconnect = true;
if rest.connect("example.com", 443, b_tls, b_auto_reconnect).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

// Add several query parameters at once from a query-string.  Use the form field1=value1&field2=value2.
let query_string = "q=chilkat&limit=10&sort=asc".to_string();
if rest.add_query_params(&query_string).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

let Ok(response_text) = rest.full_request_no_body("GET", "/api/search") else {
    println!("{}", rest.last_error_text());
    return;
};

println!("{}", response_text);