Sample code for 30+ languages & platforms
Rust

Send HTTPS POST with XML Body

See more HTTP Examples

Demonstrates how to send an HTTP (or HTTPS) POST where the body of the request is XML.

Chilkat Rust Downloads

Rust

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

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

let str_xml = "<TransactionSetup xmlns=\"https://xyz.com\"><Credentials><AccountID>XXX</AccountID></Credentials></TransactionSetup>".to_string();

// Maybe you need other headers?
http.set_request_header("Accept", "application/xml");

let resp = chilkat::HttpResponse::new();
if http.http_str("POST", "https://www.somewebsite.com/", &str_xml, "utf-8", "application/xml", &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

// Examine the response status code:
println!("response status code = {}", resp.status_code());

// Examine the response body:
println!("response body: {}", resp.body_str());