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.

"Error 415: Media Type Not Supported" when creating a campaign via API

Highlighted
Occasional Contributor

"Error 415: Media Type Not Supported" when creating a campaign via API

Hi

 

I get this error "Error 415: Media Type Not Supported" when trying to create a campaign via the API

 

Here's my XML;

 

<entry xmlns="http://www.w3.org/2005/Atom">
<id>http://api.constantcontact.com/ws/customers/username/campaigns/0</id>
<title type="text">test hello 2 OK!</title>
<updated>2012-09-20T15:10:05.491Z</updated>
<content type="application/vnd.ctct+xml">
<Campaign xmlns="http://ws.constantcontact.com/ns/1.0/">
<Name>test hello 2 OK!</Name>
<Subject>Special Deals from access</Subject>
<FromName>access</FromName>
<ViewAsWebpage>YES</ViewAsWebpage>
<PermissionReminder>YES</PermissionReminder>
<OrganizationName>access</OrganizationName>
<OrganizationAddress1>testteg</OrganizationAddress1>
<OrganizationAddress2>total city</OrganizationAddress2>
<OrganizationAddress3 />
<OrganizationCity>kjfggfkjks</OrganizationCity>
<OrganizationState />
<OrganizationInternationalState>england</OrganizationInternationalState>
<OrganizationCountry>gb</OrganizationCountry>
<OrganizationPostalCode>nn137ab</OrganizationPostalCode>
<IncludeForwardEmail>YES</IncludeForwardEmail>
<ForwardEmailLinkText>Forward this email</ForwardEmailLinkText>
<IncludeSubscribeLink>YES</IncludeSubscribeLink>
<SubscribeLinkText>Subscribe Me!</SubscribeLinkText>
<FromEmail>
<Email id="http://api.constantcontact.com/ws/customers/username/settings/emailaddresses/2">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/settings/emailaddresses/2" rel="self" />
</Email>
<EmailAddress>example@example.com</EmailAddress>
</FromEmail>
<ReplyToEmail>
<Email id="http://api.constantcontact.com/ws/customers/username/settings/emailaddresses/2">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/settings/emailaddresses/2" rel="self" />
</Email>
<EmailAddress>example@example.com</EmailAddress>
</ReplyToEmail>
<EmailContent>&amp;lt;html&gt;&amp;lt;body&gt;&amp;lt;/body&gt;&amp;lt;/html&gt;</EmailContent>
<EmailTextContent>add</EmailTextContent>
<EmailContentFormat>HTML</EmailContentFormat>
</Campaign>
</content>
<source>
<author>
<name>username</name>
</author>
</source>
</entry>

 

I send this via a 'PUT'. What am I missing?!?!?!

2 REPLIES 2
Highlighted
Employee

Re: "Error 415: Media Type Not Supported" when creating a campaign via API

Hi,

 

There were a few problems with your XML.    If you set ViewAsWebpage and PermissionReminder to "YES," you have to provide values for them.  It also looks like your email contents were double encoded, such as for the "<" character, you should encode to "&lt;" but you encoded to "&amp;lt;".  Try the XML below, filling back in you verified email address and username where appropriate.

 

<entry xmlns="http://www.w3.org/2005/Atom">
<id>http://api.constantcontact.com/ws/customers/username/campaigns/0</id>
<title type="text">test hello 2 OK!</title>
<updated>2012-09-20T15:10:05.491Z</updated>
<content type="application/vnd.ctct+xml">
<Campaign xmlns="http://ws.constantcontact.com/ns/1.0/">
<Name>test hello 3 OK!</Name>
<Subject>Special Deals from access</Subject>
<FromName>access</FromName>
<ViewAsWebpage>NO</ViewAsWebpage>
<PermissionReminder>NO</PermissionReminder>
<OrganizationName>access</OrganizationName>
<OrganizationAddress1>testteg</OrganizationAddress1>
<OrganizationAddress2>total city</OrganizationAddress2>
<OrganizationAddress3 />
<OrganizationCity>kjfggfkjks</OrganizationCity>
<OrganizationState />
<OrganizationInternationalState>england</OrganizationInternationalState>
<OrganizationCountry>gb</OrganizationCountry>
<OrganizationPostalCode>nn137ab</OrganizationPostalCode>
<IncludeForwardEmail>YES</IncludeForwardEmail>
<ForwardEmailLinkText>Forward this email</ForwardEmailLinkText>
<IncludeSubscribeLink>YES</IncludeSubscribeLink>
<SubscribeLinkText>Subscribe Me!</SubscribeLinkText>
<FromEmail>
<Email id="http://api.constantcontact.com/ws/customers/username/settings/emailaddresses/2">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/settings/emailaddresses/2" rel="self" />
</Email>
<EmailAddress>verifiedemail@example.com</EmailAddress>
</FromEmail>
<ReplyToEmail>
<Email id="http://api.constantcontact.com/ws/customers/username/settings/emailaddresses/2">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/username/settings/emailaddresses/2" rel="self" />
</Email>
<EmailAddress>verifiedemail@example.com</EmailAddress>
</ReplyToEmail>
<EmailContent>&lt;html&gt;&lt;body&gt;hello&lt;/body&gt;&lt;/html&gt;</EmailContent>
<EmailTextContent>add</EmailTextContent>
<EmailContentFormat>HTML</EmailContentFormat>
</Campaign>
</content>
<source>
<author>
<name>username</name>
</author>
</source>
</entry>

 

 

You should also be POSTing when you create a new email, and PUTting when you update the campaign.

 

Best Regards,

Shannon W.

API Support Specialist

 

 

Highlighted
Occasional Contributor

Re: "Error 415: Media Type Not Supported" when creating a campaign via API

Excellent prompt reply again.

 

Cheers

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