Tcl Requires Chilkat v11.0.0+
Tcl
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 Tcl Downloads
load ./chilkat.dll
set success 0
# Assumes Chilkat is unlocked. See Global Unlock Sample.
set vault [new_CkSecrets]
CkSecrets_put_Location $vault "local_manager"
CkSecrets_put_AutoSplit $vault 1
set entry [new_CkJsonObject]
CkJsonObject_UpdateString $entry "appName" "ConstantContactV3"
CkJsonObject_UpdateString $entry "service" "OAuth2"
CkJsonObject_UpdateString $entry "username" "my-account"
set tokens [new_CkJsonObject]
set loaded [CkSecrets_GetSecretJson $vault $entry $tokens]
if {$loaded != 1} then {
puts "Run the desktop authorization example using this account and store."
delete_CkSecrets $vault
delete_CkJsonObject $entry
delete_CkJsonObject $tokens
exit
}
if {[CkJsonObject_JsonTypeOf $tokens "access_token"] != 1} then {
puts "The saved authorization has no access token."
delete_CkSecrets $vault
delete_CkJsonObject $entry
delete_CkJsonObject $tokens
exit
}
set http [new_CkHttp]
CkHttp_put_RequireSslCertVerify $http 1
CkHttp_put_AuthToken $http [CkJsonObject_stringOf $tokens "access_token"]
set resp [new_CkHttpResponse]
# Obtain the selected contact ID from the email lookup example.
CkHttp_SetUrlVar $http "contactId" "CONTACT_ID"
set success [CkHttp_HttpNoBody $http "DELETE" "https://api.cc.email/v3/contacts/{$contactId}" $resp]
if {[CkHttpResponse_get_StatusCode $resp] == 404} then {
puts "Contact ID not found in this account."
delete_CkSecrets $vault
delete_CkJsonObject $entry
delete_CkJsonObject $tokens
delete_CkHttp $http
delete_CkHttpResponse $resp
exit
}
if {expr [$success != 1] || [[CkHttpResponse_get_StatusCode $resp] != 204]} then {
puts "Expected HTTP 204. Received [CkHttpResponse_get_StatusCode $resp]"
if {[CkHttpResponse_get_StatusCode $resp] == 401} then {
puts "Refresh the saved access token or authorize again."
}
delete_CkSecrets $vault
delete_CkJsonObject $entry
delete_CkJsonObject $tokens
delete_CkHttp $http
delete_CkHttpResponse $resp
exit
}
puts "Contact deleted and list memberships removed."
delete_CkSecrets $vault
delete_CkJsonObject $entry
delete_CkJsonObject $tokens
delete_CkHttp $http
delete_CkHttpResponse $resp