Sample code for 30+ languages & platforms
Rust

HTTP POST JSON

See more HTTP Examples

Demonstrates how to send a JSON POST and get the JSON response.

Chilkat Rust Downloads

Rust

// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code

let http = chilkat::Http::new();

let json_text = "{\"user\":\"doctoravatar@penzance.com\",\"forecast\":7,\"t\":\"vlIj\",\"zip\":94089}".to_string();

// IMPORTANT: Make sure to change the URL, JSON text,
// and other data items to your own values.  The URL used
// in this example will not actually work.

let resp = chilkat::HttpResponse::new();
if http.http_str("POST", "https://json.penzance.org/request", &json_text, "utf-8", "application/json", &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

// Display the JSON response.
println!("{}", resp.body_str());