Sample code for 30+ languages & platforms
Rust

Send a Bodyless REST Request into a StringBuilder

See more REST Examples

Demonstrates Rest.FullRequestNoBodySb, which sends a request with no body and stores the text response body in a StringBuilder.

Background. This variant of the no-body full request writes the response into a StringBuilder rather than returning it as a string, which is convenient when the response will be further processed in place.

Chilkat Rust Downloads

Rust

let rest = chilkat::Rest::new();
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;
}

// FullRequestNoBodySb sends a request with no body and stores the text response body in a
// StringBuilder.
let sb_response = chilkat::StringBuilder::new();
if rest.full_request_no_body_sb("GET", "/api/items/123", &sb_response).is_err() {
    println!("{}", rest.last_error_text());
    return;
}

let Ok(response_text) = sb_response.get_as_string() else {
    println!("{}", sb_response.last_error_text());
    return;
};

println!("{}", response_text);