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

johnf765
Occasional Participant

"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
Shannon_W
Employee

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

 

 

johnf765
Occasional Participant

Excellent prompt reply again.

 

Cheers

Developer Portal

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

Visit Page