Creating Campaigns - handling errors

I have the following scenario when creating campaigns via the API. (I'm using c#, but I imagine that shouldn't matter).

1. I call the the api.CreateCampaign function
2. Everything is fine except, say, the number of subscribers is to low
3. I handle the error message
4. The user adds more subscribers and then recreates the campaign
5. I get a "Campaign already exists" error message.

Since there appears to be no way of deleting a draft campaign via the API, how do I handle this? The result object does not return me the CampaignId I don't think. So I can't reuse it.

What the best methodology for dealing with errors when creating campaigns via the API? At the moment the only thing I can think of is to append a unique ID to the title of each campaign.

Any other suggestions?

Thanks,
Robin

Phil Phil, 7 years ago

Hi Robin,

Not allowing for duplicate draft names is basically an error trap, preventing faulty API code from creating a million identical campaigns. If the error occurs during Campaign.Create, the draft will be deleted automatically, so you don't come across this problem except when the campaign fails on send. Once the campaign is sent you can create a campaign with the same name, and since we're soon to allow for the sending of limited numbers of test campaigns, the problem will go away shortly.

In the meantime, you're right that the easiest workaround is to modify the campaign title just slightly (the subject can stay as it is). A little bit annoying, but it helps prevent worse problems, so we'll probably be leaving it in place for now!

I have put in a feature request for a Campaign.DeleteDraft procedure on your behalf, so if we start seeing the masses clamouring for that functionality it'll quickly rise up the priority list.

Hope that helps,
Phil

rmassart, 7 years ago

Hi Phil,

Thanks for the reply. Limited number of test campaigns will be useful.

The DeleteDraft campaign would be good too though. The following is the scenario I am thinking of:

My user tries to send their newsletter from our CMS. The campaign gets created, but there's a warning: "You need at least 6 subscribers". The Campaign is created but not sent, so I store the campaign id. A week later there are enough subscribers and the user has made changes to the newsletter. So I either need to update the draft campaign or delete it and recreate it. But neither is possible from API at the moment.

I know, this scenario is very unlikely, it's just something I came across in testing. And I don't know in what other cases a newsletter might be created but not sent.

Regards,
Robin

jamesd jamesd, 7 years ago

Hey all,

Our latest release added the Campaign.Delete method to the API. Documentation here: http://www.campaignmonitor.com/api/method/campaign-delete/

Hope that helps!

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098