I am using the API in an automated script which nightly removes all contacts from a particular contact list, then repopulates it with new users based on our business logic, before re-scheduling a campaign which is designated to send email to only the contacts on the aforementioned list.
Seems great except if our business logic determines no users were to be added to the list, then I have an empty list, and when you schedule the campaign this way, it causes all kinds of problems. So, I added some code to:
- Query the API for the contact list yet again
- If the contact list has a contact_count == 0 then do not schedule the campaign
This is all in place, but I am still getting error messages that the campaign can't be scheduled because the contact list is empty and it's causing me a lot of problems.
Is it possible that the API is returning false information, because I'm removing all users from the list and then just a few minutes later, re-populating that list? Any advice would be appreciated. Is there some other way of determining if a contact list is empty?
About how many contacts are you making changes to and are you using our bulk upload activity?
How long after setting a list to delete are you adding back contacts?
How long after adding the contacts back to a list are you waiting before scheduling the email?
The reason I ask is usually this is because a bulk activity will take some time to complete. It is quite possible that if you start a delete, then start an add, that the add could finish first and then be reversed by your delete activity. A list's contact count would fluxuate during these activities as well. So it is best when using any bulk activity to check if it is complete before moving on to the next step. See here for details: https://developer.constantcontact.com/docs/bulk_activities_api/bulk-activities-status-detail-report-...
Please let me know if you have any other questions!
API Support Specialist
Thanks for replying, let me answer your questions.
1) There's not enough users to really warrant the bulk contact operations. At most, we're looking at working with 1 - 3 dozen contacts in any given day.
2) Also to clarify, I'm not deleting the list, I'm actually manually removing each contact from the list and then re-adding the new contacts.
3) Time between removing all contacts and adding back in new ones: not more than 1 - 2 minutes. Time between adding contacts, and scheduling the campaign / checking to see if the list is populated: not long, almost instantly. I schedule the campaign to go off 25 minutes in the future.
Does this shed any light on the situation? I did have one revelation about this, although it's only a theory: could this happen if there's users on the list , but those users have already received the email once, hence, the list is not empty, but also when we try to send the campaign there's zero people to send it to so it breaks?
Actually, I really just wish CC would fix this problem with the API where scheduling a campaign to be sent to zero contacts messes everything up so badly.
You have come across one of the possible issues you are running in to. The way you are scheduling the email is technically considered a resend. Meaning the email will only be sent to new contacts on the list. After you have removed/added contacts and your list as a contact on it, but that contact has previously received this specific email/list combination then our system will not read that contact as valid and if they are the only contact on the list it will report that there are no contacts on the list.
So yes there are two ways to get in to the annoying status of sending to a list with no contacts. Either having no contacts on the list, or having the list contain only contacts that have already received that specific email.
Okay, so that all makes sense, but how do we fix it then? Is there a way through the API to see a list of all the email addresses who've already received the email?
Otherwise, is there any plans to fix the API so that when these conditions arise, it doesn't put the campaign in question into a buggered state? Is there somway to open an issue ticket for the api developers? I'm all for contacing them at email@example.com but this seems like something other people might be interested in knowing about.
Thank you for the concern. There is a ticket open with the department for this issue. I'll see if there is something we can do on the API side of things as well to help with this. The API has no means of knowing if a contact has or has not received a specific email; that validation occurs in a different system.
In a normal scenario the contacts for a list are not changed on such a regular basis that this scenario would not happen very often. However; with how you are managing/creating/scheduling your contact lists and campaigns I can see that this will come up again. I'll make sure your details are added to our ticket so our engineers can take them in to consideration while working towards a fix for this.
Thanks, Jimmy! Is there a bug tracking system I can access, to keep up on the status of this issue, or some other way I can stay abreast of changes to the API that might affect us?
There is not an external bug tracking system in place; however if you would like I can create a case that we can use to notify you by email once the issue is fixed by our engineers.
Just for future reference as well both David_B and myself are the same folks you would interact with if you emailed the firstname.lastname@example.org. How you contact us is up to you and depends on if there is private information needing to be exchanged.