Getting an error when previewing a campaign


We have built a send newsletter function into our website that interacts with the Campaign Monitor API. Things are largely working as they should, but we frequently get errors when previewing a campaign. The errors suggest that there is already a draft campaign on the server, but we get them when sending a draft for the very first time. They generally take this form:

Found existing draft campaign
Result of POST/api/v3/campaigns/58001803a1344d6a524aebc43dd7e7f2
Created with Campaign ID
Result of POST /api/v3/campaigns/sendpreview

Preview sending failed with code 500

We have searched the forums and tried various fixes, including adding an empty SegmentID array. We've double checked that we are retrieving campaign IDs correctly through the API, and we are always deleting campaigns before resending.

Any insights into why we might be getting errors on previews? I can attach a JSON file that contains the data we are sending to the API if that would be helpful.



ChrisB ChrisB, 3 years ago

Hey Barnaby, thanks for sending that over. This is something we'll have to get the specifics on — would you mind logging a support request? That would be the best way for us to investigate further. Thanks!

Requests can be submitted here:

Phil Phil, 3 years ago

G'day Barnaby,

I'm not sure if you've already sent in and received an answer for this, but i was able to dig through the logs and locate your case.

The issue is this: when you create a campaign through the API via a template, we do the following sequence of events:
1. Process the submitted data and ensure there are no parsing errors
2. Create the campaign and get the new campaignID
3. Kick of an asynchronous task to generate the final content of the campaign
4. Return the new campaignID without waiting for the content the generate

This means that the campaign creation call will have finished while the campaign content is still generating. Most of the time that's a total non-issue, and the campaign creation tasks will finish pretty snappily.

Sometimes though, perhaps under times of higher load or whatever, you send through a call to send a preview *before* the content has finished generation. So it excepts and throws back a 500.

That's not ideal, we would be much better off sending back a nice tidy error. But unfortunately we don't, so until that happens, my suggestion is that in the event of these 500s (only when trying to send a preview soon after creating the campaign) you wait a nominal time (say 30 seconds or a minute or so) then try again.

I hope that helps. Let me know if you have any other questions.

Barnaby, 3 years ago

Hi Chris and Phil,

Thanks very much for getting back to me. We have added a 30 second delay into the send preview operation as you suggested and that seems to have done the trick.



See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free