Sample code for 30+ languages & platforms
Rust

Aruba Fatturazione Elettronica Upload Invoice

See more Aruba Fatturazione Examples

This method must be used by the EO to send an invoice in XML format in accordance with AGID standards, but not yet digitally signed.

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://ws.fatturazioneelettronica.aruba.it/services/invoice/upload \
//   -H "Accept: application/json" \
//   -H "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" \
//   -H "Content-Type: application/json;charset=UTF-8" \
//   -d '{
//   "dataFile" : "dGVzdA==",
//   "credential" : "",
//   "domain" : ""
// }'

// 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.

// {
//   "dataFile": "dGVzdA==",
//   "credential": "",
//   "domain": ""
// }

// The dataFile field must contain an XML invoice not yet digitally signed.
let sb_invoice_xml = chilkat::StringBuilder::new();
let _ = sb_invoice_xml.load_file("qa_data/aruba/invoice123.xml", "utf-8").is_ok();

let json = chilkat::JsonObject::new();
let _ = json.update_string("dataFile", &sb_invoice_xml.get_encoded("base64", "utf-8").unwrap_or_default());
let _ = json.update_string("credential", "");
let _ = json.update_string("domain", "");

http.set_request_header("Accept", "application/json");
// Adds the "Authorization: Bearer NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=" header.
http.set_auth_token("NLOGDVXLVaF3tzmnVPkTwpkuh7dG0i09uSCcog3u+rE=");
http.set_request_header("Content-Type", "application/json;charset=UTF-8");

let resp = chilkat::HttpResponse::new();
if http.http_json("POST", "https://ws.fatturazioneelettronica.aruba.it/services/invoice/upload", &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": "0000",
//   "errorDescription": "Operazione effettuata - 521e052902be7b879d41e0fd586f0e21",
//   "uploadFileName": "IT06491598644_zbvbd.xml.p7m"
// }

// 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 upload_file_name = j_resp.string_of("uploadFileName").unwrap_or_default();