The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Create Campaign get Error json.regex.mismatch

Highlighted
New Member

Create Campaign get Error json.regex.mismatch

Hi all, I got php demo source of Constant Contact and try to test it. I created a key and token, then excute createCampaign function. But I got an error notification below. Please help me what wrong here. Thank you.

(I filled "email_content" with only simple text: "Hello world")

 

Array (

            [error_key] => json.regex.mismatch

            [error_message] => #/email_content: Value does not match the required regex pattern: (?i)<html[^>]*>[\S|\s]*<body[^>]*>[\S|\s]*[\S|\s]*$. 

)

16 REPLIES 16
Highlighted
Occasional Participant

Re: Create Campaign get Error json.regex.mismatch

Hi all,

when I input the mail content with full HTML code (<html><body><h1>hello world</h1></body></html>), the error show again no longer. But another error appear. It said that:

 

[error_key] => http.status.bad_request
[error_message] => Please enter a valid email address.

 

Althought my inputed  email is valid at 'from_addr' and 'reply_to_addr' fields.

 

Highlighted
Employee

Re: Create Campaign get Error json.regex.mismatch

Hi,

 

That second error you're getting usually indicates that the email address you are trying to associate with your email campaign isn't a verified address in your account.

 

To see verified addresses in your account, and verify more, you can log into your account and go to My Settings>>Verify Addresses.  You can send a verifiication email to yourself there, and click on a link in the email that is sent out to you in order to verify an address.

 

Best Regards,

Shannon W.

API Support Specialist

Highlighted
Occasional Participant

Re: Create Campaign get Error json.regex.mismatch

Thanks for your help. I'm sorry but I got another notification error again after doing your solution. 

I captured the result page after submit. I also print POST and error. 

Please help me. Thank you so much :)

 

This is my POST:

Array
(
         [name] => AL Campaign 1
         [subject] => AL Newsletter
         [from_name] => AL Admin
         [from_addr] => redacted@email.com
         [text_content] => Hello world
         [email_content] =>
                          <html><body>Hello world</body></html>

         [greeting_string] => Hi all
         [reply_to_addr] => redacted@email.com
         [lists] => Array
         (
                    [0] => 1
         )

         [schedule_time] => 2013-07-14T17:25:56.000Z
         [format] => HTML
)

 

And the error:

[error_key] => http.status.bad_request
[error_message] => Please enter an address

 

Highlighted
Honored Contributor

Re: Create Campaign get Error json.regex.mismatch

Hello,

 

In this case, your JSON for creating an email is correct, but you are missing an important default setting for your account.

 

In Constant Contact we require a phyiscal address to be sent with every email message so that we can comply with US anti-spam laws. there is a default email address that you can set for your Constant Contact account by going to My Settings -> Organization Address -> Edit Address. Until this has been set, your email campaigns are created without a physical address and cannot be scheduled until one has been added.

 

Once you've gone into the Constant Contact account you're working with and added an address, you should be able to make the same request successfully.

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
Highlighted
Occasional Participant

Re: Create Campaign get Error json.regex.mismatch

Hi Elijah_G, thanks for your help, but I have not yet solved this problem. I accessed to my account and set a physical address like your instruction. That's all or I need to choice this physical address when I create a campaign ... and how to do it. Please give some instructions.

Thank you so much.

Highlighted
Honored Contributor

Re: Create Campaign get Error json.regex.mismatch

Hello,

 

Once you have set up the organization address on the account that you are using with the API, then that address will be automatically used for all emails that you create. However, you can also specify the address on a per-campaign basis as well. The JSON format for that can be found on this page listed under message_footer.

 

If you are still stuck after setting the organization address on your Constant Contact account and/or setting the address on the campaign, please reply to this post and I will be happy to help!

 

Sincerely,

Elijah G.

API Support Specialist

Elijah G.
API Support Engineer
Highlighted
Occasional Participant

Re: Create Campaign get Error json.regex.mismatch

Hi mod, thank you for your help. I run the demo code again, and it's successfull. But when I integrate to my website (with the same key/token), it through the error: {"error_key":"json.enumeration.invalid","error_message":"#/message_footer/country: Instance value does not match any enum value. Valid options are:.......}

 

And another problem, at demo code, when I create campaign, it's said: 

{"error_key":"json.invalid.value.no_script_tags","error_message":"#/email_content: Field does not support script content."}

 

Suggest me any solution, please.

Thank you.

Highlighted
Occasional Participant

Re: Create Campaign get Error json.regex.mismatch

About {"error_key":"json.invalid.value.no_script_tags","error_message":"#/email_content: Field does not support script content."}

 

This is the html code which I used when try creating campaign:

 

<html><body>
<table background="http://theoptimist.com/design/optimist/images/newsletter/bg_content.png" width="100%">
<tr>
<td colspan="2" valign="top" align="center" bgcolor="#ffffff" width="645" height="168" background="http://theoptimist.com/design/optimist/images/newsletter/footer.png" style="text-align:center;">
<p style="color:#fff; font-size:14px; height:35px; text-align:center; display:block; margin-top:12px;">Follow Us On

 

<span style="margin-left:20px; "><a href="#"><img src="http://theoptimist.com/design/optimist/images/newsletter/icon_google.png" width="30" height="30" alt="" border="0" style="display:inline-block; vertical-align:middle; " /></a></span>

</p>
<p style="margin-top:50px; text-align:center; display:block;">You are receiving this email because we love working with you,<br />
if you no longer wish to receive mail from us you can <a href="#" style="color:#000;">unsubscribe here</a></p>
</td>
</tr>
</table></body></html>

 

 

 

In fact, my html code is more complex, but I must debug the error by the way delete step by step suspicious blocks. With the code block above, I confirm that "<SPAN..." block is the cause of error, but I don't know the reason why. Would you please help me review above code, and point out the error code.

 

Thank you so much

Highlighted
Employee

Re: Create Campaign get Error json.regex.mismatch

Hi,

 

Sorry for the difficulty here.  I was able to verify that our security filters aren't accepting display:inline-block and have forwarded on the difficulty to our engineers so that they can fix the underlying issue (valid CSS getting filtered).

 

In the meantime, if you split up the style into style="display:inline; display:block" it should go through.  Sorry again for the trouble.

 

Best Regards,

Shannon W.

API Support Specialist

Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured