Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

Xero Delete Account

See more Xero Examples

Deletes an account in a Xero company (Accounting API).

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 json_token = chilkat::JsonObject::new();
if json_token.load_file("qa_data/tokens/xero-access-token.json").is_err() {
    println!("{}", json_token.last_error_text());
    return;
}

http.set_auth_token(&json_token.string_of("access_token").unwrap_or_default());

// Replace the value here with an actual tenant ID obtained from this example:
// Get Xero Tenant IDs
http.set_request_header("Xero-tenant-id", "83299b9e-5747-4a14-a18a-a6c94f824eb7");

http.set_accept("application/json");

let url = "https://api.xero.com/api.xro/2.0/Accounts/54ddab14-4a8d-45cf-86be-076c99a0cea0".to_string();

let resp = chilkat::HttpResponse::new();
if http.http_no_body("DELETE", &url, &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

// A 200 status code indicates success.
println!("Response Status Code: {}", resp.status_code());
println!("Response Body:");
println!("{}", resp.body_str());