Sample code for 30+ languages & platforms
Rust

qa.factura1.com.co Obtain Auth Token

See more HTTP Misc Examples

Demonstrates how to send a JSON POST to get an authenticataion token for qa.factura1.com.co

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();

// Build the following JSON
// {
//   "password": "MY_PASSWORD",
//   "username": "MY_USERNAME"
// }

let json = chilkat::JsonObject::new();
json.set_emit_compact(false);
let _ = json.update_string("password", "MY_PASSWORD");
let _ = json.update_string("username", "MY_USERNAME");

let resp = chilkat::HttpResponse::new();
if http.http_json("POST", "https://qa.factura1.com.co/v2/auth", &json, "application/json", &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

let json_resp = chilkat::JsonObject::new();
json_resp.set_emit_compact(false);
let _ = json_resp.load(&resp.body_str());

println!("{}", json_resp.emit().unwrap_or_default());

println!("Access token: {}", json_resp.string_of("token").unwrap_or_default());