Error 400: Invalid Content with PHP-SDK

SOLVED
Go to solution
Occasional Participant

Error 400: Invalid Content with PHP-SDK

Hello, 

 

I'm trying to use the PHP-SDK with the v2 API to create an email campaign. 

 

Right now if I try to make the call, it returns with an error of: Error 400: Invalid Content.

 

If I replace my HTML content with <html><body>Hi</body></html> it goes through fine. 

However, I can't see anything wrong with the HTML I've sent as the content currently. Are there certain things that it doesn't like?

Included below is an example of html_content that did not work.

<html> <body style="background:white"> <table> <tr><td width = 350> <a href="http://www.wmwa.net/index.php"><img border=0 width=225 height=59 src="http://www.wmwa.net/images/WMWAEmailLogo.jpg"> </a></td><td width=500 align=center style="font-size:20px"><b>BizSys eNotification</b></td></tr> <tr><td style="font-size:12px"><i><b><br>ISO Registered ISO9001:2008</b></i></td><td rowspan=2 align=center><img src="http://www.wmwa.net/images/email_Notification2.jpg"></td></tr> <tr><td style="color:#AE4600;font-size:22px"><span style="color:black;"><Property name="Subscriber.FirstName"/><Property name="Subscriber.FamilyName"/></span><i><b><br>Welcome to Email Campaigns<br></b></i></td><td></td></tr> <tr><td colspan=2><p> <div id="salesData">Let's go, <Property name="Subscriber.Email"/>.</div></td></tr> </table> </body> </html>
1 ACCEPTED SOLUTION
Member

Hello,

 

If you are setting the email_content_format to XHTML, then there is a strict validation required on the input code. However, if you set the format as HTML, then the validation is much less strict. given that I see you are using <Property> tags, the code is failing to be accepted because it is not XHTML valid.

 

Here are some specific items I noticed that need correction:

  • Your self-closing tags are missing the closing /. Example: <br> instead of <br /> or <img attributes... />
  • Many of your attributes are missing quotes around the values. Example: <td width = 350> instead of <td width="350">

 

If you correct these issues, you should be able to get up and running. One thing that can help you greatly with testing is to use our UI interface for creating XHTML emails to test if your code is valid. You can find directions for that here: 

http://knowledgebase.constantcontact.com/articles/KnowledgeBase/5252-create-a-custom-code-email-camp...

 

Please let me know if you have any questions!

 

Sincerely,

 

 

Elijah G.
API Support Engineer

View solution in original post

1 REPLY 1
Member

Hello,

 

If you are setting the email_content_format to XHTML, then there is a strict validation required on the input code. However, if you set the format as HTML, then the validation is much less strict. given that I see you are using <Property> tags, the code is failing to be accepted because it is not XHTML valid.

 

Here are some specific items I noticed that need correction:

  • Your self-closing tags are missing the closing /. Example: <br> instead of <br /> or <img attributes... />
  • Many of your attributes are missing quotes around the values. Example: <td width = 350> instead of <td width="350">

 

If you correct these issues, you should be able to get up and running. One thing that can help you greatly with testing is to use our UI interface for creating XHTML emails to test if your code is valid. You can find directions for that here: 

http://knowledgebase.constantcontact.com/articles/KnowledgeBase/5252-create-a-custom-code-email-camp...

 

Please let me know if you have any questions!

 

Sincerely,

 

 

Elijah G.
API Support Engineer

View solution in original post

Developer Portal

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

Visit Page