Sample code for 30+ languages & platforms
Rust

Cerved API Entity Contacts

See more Cerved Examples

The service returns the list of contacts of a Subject (legal entities) identified by "id_soggetto"

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 GET \
//   https://api.cerved.com/cervedApi/v1/entityProfile/contacts?id_soggetto=12345678 \
//   -H 'accept: application/json' \
//   -H 'apikey: ********************************'

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

http.set_request_header("accept", "application/json");
http.set_request_header("apikey", "********************************");

let sb_response_body = chilkat::StringBuilder::new();
if http.quick_get_sb("https://api.cerved.com/cervedApi/v1/entityProfile/contacts?id_soggetto=12345678", &sb_response_body).is_err() {
    println!("{}", http.last_error_text());
    return;
}

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 = http.last_status();
println!("Response Status Code = {}", resp_status_code);
if resp_status_code >= 400 {
    println!("Response Header:");
    println!("{}", http.last_header());
    println!("Failed.");
    return;
}

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

// {
//   "indirizzi_email": [
//     {
//       "email": "string",
//       "categoria": "string"
//     }
//   ],
//   "indirizzi_email_certificate": [
//     {
//       "email": "string",
//       "categoria": "string"
//     }
//   ],
//   "telefoni": [
//     {
//       "fonte": "string",
//       "sede": "string",
//       "numero": "string",
//       "uso": "string"
//     }
//   ],
//   "siti_web": [
//     {
//       "url": "string",
//       "tipo": "string"
//     }
//   ]
// }

// 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 mut i = 0;
let mut count_i = j_resp.size_of_array("indirizzi_email");
while i < count_i {
    j_resp.set_i(i);
    let _ = j_resp.string_of("indirizzi_email[i].email").unwrap_or_default();
    let _ = j_resp.string_of("indirizzi_email[i].categoria").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = j_resp.size_of_array("indirizzi_email_certificate");
while i < count_i {
    j_resp.set_i(i);
    let _ = j_resp.string_of("indirizzi_email_certificate[i].email").unwrap_or_default();
    let _ = j_resp.string_of("indirizzi_email_certificate[i].categoria").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = j_resp.size_of_array("telefoni");
while i < count_i {
    j_resp.set_i(i);
    let _ = j_resp.string_of("telefoni[i].fonte").unwrap_or_default();
    let _ = j_resp.string_of("telefoni[i].sede").unwrap_or_default();
    let _ = j_resp.string_of("telefoni[i].numero").unwrap_or_default();
    let _ = j_resp.string_of("telefoni[i].uso").unwrap_or_default();
    i = i + 1;
}

i = 0;
count_i = j_resp.size_of_array("siti_web");
while i < count_i {
    j_resp.set_i(i);
    let _ = j_resp.string_of("siti_web[i].url").unwrap_or_default();
    let _ = j_resp.string_of("siti_web[i].tipo").unwrap_or_default();
    i = i + 1;
}