Hello.
I am trying to delete a contact using a curl command from the command-line on a Mac, but am getting an error message saying that I do no have permission to perform this action.
The syntax of the command that I am issuing is:
curl -X PUT "https://api.constantcontact.com/v2/contacts?api_key=API_KEY&access_token=ACCESS_TOKEN&action_by=ACTI..." -H "Content-Type: application/json" -d "\"email_addresses\":[{\"id\":\"EMAIL_ADDRESS_ID\"}],\"lists\":[{}]\""
I am using a valid API key, access token and email address id, and I found a posting elsewhere on this site that said that in order to delete a contact one has to assign a null set of lists to that contact.
The full error message that I get when issuing the above command is:
[{"error_key":"user.privilege.forbidden","error_message":"You don't have permission to perform this action; please see your account owner."}]
Can you advise me on the correct format for a curl command to delete a contact or otherwise unsubscribe them from all lists? Or is there something else that I need to do with the setup of my API key in order to be able to delete contacts?
Thank you.
Hello,
Thank you for reaching out to Constant Contact API Support.
The first thing I notice is that you need to include the ID of the contact that you are updating in your URL path. You also need to include the contact's email address. See the below example:
curl -X PUT \ 'https://api.constantcontact.com/v2/contacts/{contactId}?api_key={API Key}' \ -H 'Authorization: Bearer {Access Token}' \ -H 'Cache-Control: no-cache' \ -H 'Content-Type: application/json' \ -d '{ "lists": [], "email_addresses": [ { "email_address": "email@address.here" } ] }'
You can see the full documentation for making this call at https://v2.developer.constantcontact.com/docs/contacts-api/contacts-resource.html?method=PUT
Please let me know if you have any other questions and I'll be happy to help in any way I can!
Regards,
David Bornstein
Tier II API Support Engineer
Hello.
Thank you for your reply.
When I try your suggestion, I now get this error message:
[{"error_key":"http.status.not_found","error_message":"No matching resource was found for the supplied URL."}]
What does this error message mean, and what can be done to avoid it?
Thank you.
I've identified what the problem was that was causing the "No matching resource was found for the supplied URL" message - I was using the email address ID instead of the contact ID. Once I used the correct ID, the curl command worked.
Thank you again.
Announcements
Join our list to be notified of new features and updates to our V3 API.
Sign Up