Hi there, We are trying to create a new campaign using API v3 and getting 400 error
but when the same html is put in front end it works
PFB Details of the call
Url: https://api.cc.email/v3/emails
Headers Array: ["authorization: Bearer TOKEN","cache-control: no-cache","Content-Type: application\/json","Accept: *\/*"]
Payload: {"name":"Constant Contact Emailer 02","email_campaign_activities":[{"format_type":"1","from_name":"Gaurav Mendiratta","from_email":"developer@edivo.io","reply_to_email":"developer@edivo.io","subject":"#CREATOR_FULL_NAME# has shared a #TEMPLATE_TYPE# with you","html_content":"<html><head> <meta charset='utf-8'> <meta name='viewport' content='width=device-width'> <meta http-equiv='X-UA-Compatible' content='IE=edge'> <meta name='x-apple-disable-message-reformatting'> <link href='https://fonts.googleapis.com/css?family=Arimo' rel='stylesheet'> <title></title> <style> html, body { margin: 0 auto !important; padding: 0 !important; height: 100% !important; width: 100% !important; } * { -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; } div[style*='margin: 16px 0'] { margin: 0 !important; } table, td { mso-table-lspace: 0pt !important; mso-table-rspace: 0pt !important; } table { border-spacing: 0 !important; border-collapse: collapse !important; table-layout: fixed !important; margin: 0 auto !important; } table table table { table-layout: auto; } img { -ms-interpolation-mode: bicubic; } *[x-apple-data-detectors] { color: inherit !important; text-decoration: none !important; } .x-gmail-data-detectors, .x-gmail-data-detectors *, .aBn { border-bottom: 0 !important; cursor: default !important; } .a6S { display: none !important; opacity: 0.01 !important; } img.g-img + div { display: none !important; } .button-link { text-decoration: none !important; } </style> <style> /* What it does: Hover styles for buttons */ .button-td, .button-a { transition: all 100ms ease-in; } .button-td:hover, .button-a:hover { background: #aaa2a2 !important; border-color: #aaa2a2 !important; } /* Media Queries */ @media screen and (max-width: 600px) { .email-container { width: 100% !important; margin: auto !important; } /* What it does: Forces elements to resize to the full width of their container. Useful for resizing images beyond their max-width. */ .fluid { max-width: 100% !important; height: auto !important; margin-left: auto !important; margin-right: auto !important; } /* What it does: Forces table cells into full-width rows. */ .stack-column, .stack-column-center { display: block !important; width: 100% !important; max-width: 100% !important; direction: ltr !important; } /* And center justify these ones. */ .stack-column-center { text-align: center !important; } /* What it does: Generic utility class for centering. Useful for images, buttons, and nested tables. */ .center-on-narrow { text-align: center !important; display: block !important; margin-left: auto !important; margin-right: auto !important; float: none !important; } table.center-on-narrow { display: inline-block !important; } /* What it does: Adjust typography on small screens to improve readability */ .email-container p { font-size: 17px !important; line-height: 22px !important; }\timg, video{ width:100% !important; } } .video-wrapper { display:none; } @media (-webkit-min-device-pixel-ratio: 0) and (min-device-width:1024px) { .video-wrapper { display:block!important; } .video-fallback { display:none!important; } } @supports (-webkit-overflow-scrolling:touch) and (color:#ffffffff) { div[class^=video-wrapper] { display:block!important; } div[class^=video-fallback] { display:none!important; } } #MessageViewBody .video-wrapper { display:block!important; } #MessageViewBody .video-fallback { display:none!important; } </style></head><body width='100%' style='margin: 0; mso-line-height-rule: exactly;'><center style='width: 100%; text-align: left;'> <table role='presentation' aria-hidden='true' cellspacing='0' cellpadding='0' border='0' align='center' width='800' style='margin: auto;' class='email-container'> <tr style='border-right:1px solid #ddd;border-left:1px solid #ddd;'> <td bgcolor='#7054a6' align='center' style='background: rgb(66,183,194);\tbackground: -moz-linear-gradient(top, rgb(66,183,194) 0%, rgb(62,135,174) 47%, rgb(99,90,155) 100%);\tbackground: -webkit-gradient(left top, left bottom, color-stop(0%, rgb(66,183,194)), color-stop(47%, rgb(62,135,174)), color-stop(100%, rgb(99,90,155)));\tbackground: -webkit-linear-gradient(top, rgb(66,183,194) 0%, rgb(62,135,174) 47%, rgb(99,90,155) 100%);\tbackground: -o-linear-gradient(top, rgb(66,183,194) 0%, rgb(62,135,174) 47%, rgb(99,90,155) 100%);\tbackground: -ms-linear-gradient(top, rgb(66,183,194) 0%, rgb(62,135,174) 47%, rgb(99,90,155) 100%);\tbackground: linear-gradient(to bottom, rgb(66,183,194) 0%, rgb(62,135,174) 47%, rgb(99,90,155) 100%);\tfilter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#42b7c2', endColorstr='#635a9b', GradientType=0 );'> <img src='https://www.edivo.io/assets/images/edivo/edivo-logo.png' class='center-on-narrow' aria-hidden='true' width='165' height='auto' alt='' border='0' align='center' style='background:transparent;padding: 30px 0px;'> </td> </tr> <tr style='border-right:1px solid #ddd;border-top:0px;border-left:1px solid #ddd;'> <td align='center' bgcolor='#615c9c'> <table width='80%' align='center' border='0' cellpadding='0' cellspacing='0' style='background-color:#ececec;'> <tbody> <tr> <td height='25'></td> </tr> <tr> <td align='center' style='font-family: 'Arimo', sans-serif;font-size: 20px;color: #7054a6;line-height: 24.65px;font-weight: 600;'> Hello $Subscriber.FirstName! </td> </tr> <tr> <td height='15'></td> </tr> </tbody> </table> </td> </tr> <tr style='background-color: #ececec; border-right:1px solid #ddd;border-bottom:1px solid #ddd;border-left:1px solid #ddd;'> <td align='center' bgcolor='#fff'> <table width='80%' align='center' border='0' cellpadding='0' cellspacing='0' style='background-color:#ececec'> <tbody> <tr> <td> <table width='100%' align='left' border='0' cellpadding='0' cellspacing='0'> <tbody> <tr style='background-color:#ececec;'> <td height='20'></td> </tr> <p style='background-color:#ececec;text-align: center;font-family: 'Arimo', sans-serif;font-size: 15px;padding: 0px 10px;color: #535353;line-height: 20px;font-weight: normal;margin: 0'><span>image</span> with you. </p> <tr> <td bgcolor='#ececec' style='padding: 0 0px 25px; font-family: sans-serif; font-size: 15px; line-height: 20px; color: #555555;'> <table role='presentation' aria-hidden='true' cellspacing='0' cellpadding='0' border='0' align='center' style='margin: auto'> <tbody><tr> <td style='border-radius: 3px; background: #ececec; text-align: center;' class=''> <a href='$Subscriber.Custom.Edivo_preview_url' style='display: inline-block; margin-bottom: 20px;text-decoration:none;' class=''> <div class='image-preview'> <a href='$Subscriber.Custom.Edivo_preview_url' style='text-decoration: none;'> <div><img src='$Subscriber.Custom.Edivo_preview_url' style='height: auto;width:320px;' alt='personalized image' /></div> <div style='color:#ffffff;background-color: #615c9c;padding: 10px 20px;width:180px;display:inline-block;margin: 10px auto;'>View</div> </a> </div> </a> </td> </tr> </tbody></table> </td> </tr> </tbody> </table> </td> </tr> <tr> <td bgcolor='#ffffff'> <table role='presentation' aria-hidden='true' cellspacing='0' cellpadding='0' border='0' width='100%'> <tbody> <tr> <td style='padding: 20px 0 10px 0;font-family: sans-serif; font-size: 14px; line-height: 20px; color: #757575;'> \u00a9 2018 - 2019 Edivo </td> </tr> <tr> <td style='padding: 0px; font-family: sans-serif; font-size: 12px; line-height: 20px; color: #757575;'> This message was sent to <a href='$Subscriber.Email' style='text-decoration:none;color:#757575;'><u>$Subscriber.Email</u></a> and intended for $Subscriber.FirstName. </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </table></center></body></html>"}]}
Solved! Go to Solution.
Hi @edivodev,
It appears the issue is related to character sets. The v3 API does not currently support the UTF-8 character set; this is something we are working on correcting.
As a work around you can set your header to "Content-Type: application/json; charset=utf-8" and this should allow you to make your POST correctly.
Hello @edivodev,
Thank you for reaching out to Constant Contact's API Support.
It seems our v3 API does not like your HTML, but our v2 API and as you already noticed our UI accept it just fine. I've brought this to our engineers attention and we'll look in to it.
Hey Jimmy
Any update on this issue, we have a client roll out waiting because of this bug.
Hi @edivodev,
Due to the holidays we are on a code freeze which means there will be no changes made. I'll see if I can get an update for after that timeframe.
Hi @edivodev,
It appears the issue is related to character sets. The v3 API does not currently support the UTF-8 character set; this is something we are working on correcting.
As a work around you can set your header to "Content-Type: application/json; charset=utf-8" and this should allow you to make your POST correctly.
Hi Jimmy
Happy new year.
Thank you, above solution worked.
Announcements
Join our list to be notified of new features and updates to our V3 API.
Sign Up