Sample code for 30+ languages & platforms
Rust

Aruba Fatturazione Elettronica CreateTransmissionRequest

See more Aruba Fatturazione Examples

Creation of a new request for the transmission of "Financial Communications" (single file transmission request).

Chilkat Rust Downloads

Rust

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

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

// Implements the following CURL command:

// curl -X POST https://auth.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequest \
//   -H "Accept: application/json" \
//   -H "Content-Type: application/json;charset=UTF-8" \
//   -d '{
//   "userName" : "ARUBA0000",
//   "password" : "ArubaPwd",
//   "userID" : "ARUBA0000",
//   "comunicationType" : "LI",
//   "dataFile" : "dGVzdA=="
// }'

// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code

// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON

// The following JSON is sent in the request body.

// {
//   "userName": "ARUBA0000",
//   "password": "ArubaPwd",
//   "userID": "ARUBA0000",
//   "comunicationType": "LI",
//   "dataFile": "dGVzdA=="
// }

// The dataFile field must contain an xml document which conforms to the Revenue Agency specifications.
// The document must be Base64 codified and contain a CADES-based electronic signature.
let sb_signed_xml = chilkat::StringBuilder::new();
let _ = sb_signed_xml.load_file("qa_data/aruba/sampleXmlDoc.xml", "utf-8").is_ok();

let json = chilkat::JsonObject::new();
let _ = json.update_string("userName", "ARUBA0000");
let _ = json.update_string("password", "ArubaPwd");
let _ = json.update_string("userID", "ARUBA0000");
let _ = json.update_string("comunicationType", "LI");
let _ = json.update_string("dataFile", &sb_signed_xml.get_encoded("base64", "utf-8").unwrap_or_default());

http.set_request_header("Content-Type", "application/json;charset=UTF-8");
http.set_request_header("Accept", "application/json");

let resp = chilkat::HttpResponse::new();
if http.http_json("POST", "https://ws.fatturazioneelettronica.aruba.it/services/ClientRequest/CreateTransmissionRequest", &json, "application/json", &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

let sb_response_body = chilkat::StringBuilder::new();
let _ = resp.get_body_sb(&sb_response_body);
let j_resp = chilkat::JsonObject::new();
let _ = j_resp.load_sb(&sb_response_body);
j_resp.set_emit_compact(false);

println!("Response Body:");
println!("{}", j_resp.emit().unwrap_or_default());

let resp_status_code = resp.status_code();
println!("Response Status Code = {}", resp_status_code);
if resp_status_code >= 400 {
    println!("Response Header:");
    println!("{}", resp.header());
    println!("Failed.");
    return;
}

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "errorCode": "",
//   "errorDescription": "",
//   "requestID": "UICBY9QDLUOXQ72U"
// }

// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON

let error_code = j_resp.string_of("errorCode").unwrap_or_default();
let error_description = j_resp.string_of("errorDescription").unwrap_or_default();
let request_id = j_resp.string_of("requestID").unwrap_or_default();