ElasticEmail / ElasticEmail.WebApiClient-js

Deprecated library. Easily send emails with Elastic Email using Web API JS Client https://elasticemail.com/
MIT License
15 stars 9 forks source link

How to create a non-scheduled campaign from the API #4

Closed michaelrambeau closed 6 years ago

michaelrambeau commented 6 years ago

Hello, First, thank you for your service that I use to send a newsletter about JavaScript trends: https://weekly.bestofjs.org/. I try to create a campaign using the campaign/add end point from the API.

A parameter named campaign is expected. When I use the following value:

{
  name: 'My campaign',
  targets: [l123],
  CampaignTemplates: [
    {
      TemplateID: '5213',
      TemplateSubject: 'My subject',
      TemplateFromEmail: 'hello@bestofjs.org',
      TemplateReplyEmail: 'hello@bestofjs.org',
      TemplateReplyName: 'Best of JavaScript'
    }
  ],
  TriggerType: 1 // 1 means "SendNow"
}

...I get the following error:

Trigger count and trigger frequency can only be set for scheduled campaigns

But I don't pass any "trigger" parameter and I don't want a scheduled newsletter, I want to send it manually later.

Am I missing something? How can I unset the "trigger" parameters? Thank you very much for your help!

ppodolak commented 6 years ago

@michaelrambeau Hi, It's good to hear you found our service useful 👍. Sorry for late answer but we had to adjust our api for better coverage of your problem. Now you can just set CampaignStatus as Draft, then you can just set manualy on demand to Active.

michaelrambeau commented 6 years ago

Hello @ppodolak Thank you for your answer. Setting the CampaignStatus to Draft worked, no error, but the campaign that was created was not a "Draft", it was a "Regular" one and its status was "Sending".

image

Is it the expected behavior? Thank you again for your help!

ppodolak commented 6 years ago

@michaelrambeau I will look into it, could show the params you are setting for this request?

michaelrambeau commented 6 years ago

@ppodolak Here is the campaign parameter (the same as before, plus CampaignStatus):

{
  name: 'My campaign',
  targets: ['l528'],
  CampaignTemplates: [
    {
      TemplateID: '5213',
      TemplateSubject: 'My subject',
      TemplateFromEmail: 'hello@bestofjs.org',
      TemplateReplyEmail: 'hello@bestofjs.org',
      TemplateReplyName: 'Best of JavaScript'
    }
  ],
  TriggerType: 1,
  CampaignStatus: 'Draft' // added!
}
ppodolak commented 6 years ago

@michaelrambeau Sorry my bad, the param should be named Status not CampaignStatus. Hope that helps!

michaelrambeau commented 6 years ago

@ppodolak It works, thank you very much Pawel!

Closing the issue but let me know if I could to any test for you.