C# Requires Chilkat v11.0.0+
C#
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 C# Downloads
bool success = false;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
Chilkat.Secrets vault = new Chilkat.Secrets();
vault.Location = "local_manager";
vault.AutoSplit = true;
Chilkat.JsonObject entry = new Chilkat.JsonObject();
entry.UpdateString("appName","ConstantContactV3");
entry.UpdateString("service","OAuth2");
entry.UpdateString("username","my-account");
Chilkat.JsonObject tokens = new Chilkat.JsonObject();
bool loaded = vault.GetSecretJson(entry,tokens);
if (loaded != true) {
Debug.WriteLine("Run the desktop authorization example using this account and store.");
return;
}
if (tokens.JsonTypeOf("access_token") != 1) {
Debug.WriteLine("The saved authorization has no access token.");
return;
}
Chilkat.Http http = new Chilkat.Http();
http.RequireSslCertVerify = true;
http.AuthToken = tokens.StringOf("access_token");
Chilkat.HttpResponse resp = new Chilkat.HttpResponse();
// Obtain the selected contact ID from the email lookup example.
http.SetUrlVar("contactId","CONTACT_ID");
success = http.HttpNoBody("DELETE","https://api.cc.email/v3/contacts/{$contactId}",resp);
if (resp.StatusCode == 404) {
Debug.WriteLine("Contact ID not found in this account.");
return;
}
if ((success != true) || (resp.StatusCode != 204)) {
Debug.WriteLine("Expected HTTP 204. Received " + Convert.ToString(resp.StatusCode));
if (resp.StatusCode == 401) {
Debug.WriteLine("Refresh the saved access token or authorize again.");
}
return;
}
Debug.WriteLine("Contact deleted and list memberships removed.");