Rust Requires Chilkat v11.0.0+
Rust
Constant Contact V3: Delete a contact by ID
See more Constant Contact Examples
Use the ID of the contact selected for deletion. Deletion removes all list memberships and sets the deletion timestamp. Unsubscribing is a separate operation that changes permission to send. A successful delete returns HTTP 204 with an empty body. To bring the record back, see Restore a deleted contact. Authorize the app first and use the same credential store.
Constant Contact developer guide
Chilkat Rust Downloads
let mut success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
let vault = chilkat::Secrets::new();
vault.set_location("local_manager");
vault.set_auto_split(true);
let entry = chilkat::JsonObject::new();
let _ = entry.update_string("appName", "ConstantContactV3");
let _ = entry.update_string("service", "OAuth2");
let _ = entry.update_string("username", "my-account");
let tokens = chilkat::JsonObject::new();
if vault.get_secret_json(&entry, &tokens).is_err() {
println!("Run the desktop authorization example using this account and store.");
return;
}
if tokens.json_type_of("access_token") != 1 {
println!("The saved authorization has no access token.");
return;
}
let http = chilkat::Http::new();
http.set_require_ssl_cert_verify(true);
http.set_auth_token(&tokens.string_of("access_token").unwrap_or_default());
let resp = chilkat::HttpResponse::new();
// Obtain the selected contact ID from the email lookup example.
let _ = http.set_url_var("contactId", "CONTACT_ID");
success = http.http_no_body("DELETE", "https://api.cc.email/v3/contacts/{$contactId}", &resp).is_ok();
if resp.status_code() == 404 {
println!("Contact ID not found in this account.");
return;
}
if (!success) || (resp.status_code() != 204) {
println!("Expected HTTP 204. Received {}", resp.status_code());
if resp.status_code() == 401 {
println!("Refresh the saved access token or authorize again.");
}
return;
}
println!("Contact deleted and list memberships removed.");