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 - couldn't connect to host

Highlighted
Frequent Visitor

Create campaign - couldn't connect to host

Hi!

 

I have this really odd problem... I wrote an API wrapper for email services in my website. Problem is, all of the API functionality works except for creating a campaign.

 

The error my framework throws is:

Error fetching remote https://api.constantcontact.com/ws/customers/bagnz0r/campaigns [ status 0 ] couldn't connect to host

 

Which is really odd, because I believe that request is correct and I have provided with correct url.

 

This is the code:

http://pastebin.com/qek5jaer

http://pastebin.com/nr0hW8wb

 

XML that is produced and sent:

http://pastebin.com/GzdWmbsp

1 REPLY 1
Highlighted
Employee

Re: Create campaign - couldn't connect to host

Hey,

 

It appears to me that it is returning the wrong error as your XML is invalid.  You should be getting back a 400 error.  Take a look at my revised XML entry which should go right into your account.  You were missing the organization information, replytoemailaddress.

 

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <link href="/ws/customers/apisupport/campaigns" rel="edit"/>
    <id>http://api.constantcontact.com/ws/customers/apisupport/campaigns</id>
    <title type="text">Sample AdSwaps campaign</title>
    <updated>2011-11-02T18:37:06+01:00</updated>
    <author>
        <name>AdSwaps</name>
    </author>
    <content type="application/vnd.ctct+xml">
        <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/">
            <Name>1Sample AdSwaps campaign</Name>
            <Status>Draft</Status>
            <Date>2011-11-02T18:37:06+01:00</Date>
            <Subject>Sample AdSwaps campaign email</Subject>
            <FromName>bagnohax@gmail.com</FromName>
            <ViewAsWebpage>NO</ViewAsWebpage>
            <ViewAsWebpageLinkText></ViewAsWebpageLinkText>
            <ViewAsWebpageText></ViewAsWebpageText>
            <PermissionReminder>NO</PermissionReminder>
            <PermissionReminderText></PermissionReminderText>
            <GreetingSalutation>Dear</GreetingSalutation>
            <GreetingName>FirstName</GreetingName>
            <GreetingString>Greetings!</GreetingString>
            <OrganizationName>ctct</OrganizationName>
            <OrganizationAddress1>123 wsw st</OrganizationAddress1>
            <OrganizationAddress2></OrganizationAddress2>
            <OrganizationAddress3></OrganizationAddress3>
            <OrganizationCity>Ashland</OrganizationCity>
            <OrganizationState>MA</OrganizationState>
            <OrganizationInternationalState></OrganizationInternationalState>
            <OrganizationCountry>us</OrganizationCountry>
            <OrganizationPostalCode>32423</OrganizationPostalCode>
            <IncludeForwardEmail>NO</IncludeForwardEmail>
            <ForwardEmailLinkText></ForwardEmailLinkText>
            <IncludeSubscribeLink>NO</IncludeSubscribeLink>
            <SubscribeLinkText></SubscribeLinkText>
            <EmailContentFormat>HTML</EmailContentFormat>
            <EmailContent>&lt;html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" 
                xmlns:cctd="http://www.constantcontact.com/cctd">
                &lt;body>&lt;CopyRight>Copyright (c) 1996-2009 Constant Contact. All rights reserved.  Except as permitted under a
                separate
                written agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on any
                Constant Contact site,
                including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, or
                distributed without the
                prior written permission of Constant Contact.  For inquiries regarding reproduction or distribution of any Constant
                Contact material, please
                contact joesflowers@example.com.&lt;/CopyRight>
                &lt;OpenTracking/>
                &lt;!--  Do NOT delete previous line if you want to get statistics on the number of opened emails -->
                &lt;CustomBlock name="letter.intro" title="Personalization">
                &lt;Greeting/>
                &lt;/CustomBlock>
                &lt;/body>
                &lt;/html></EmailContent>
            <EmailTextContent>&lt;Text&gt;Hi there, This is a sample AdSwaps email campaign. --- XYZ
                Corporation.&lt;/Text&gt;</EmailTextContent>
            <StyleSheet></StyleSheet>
            <ContactLists>
                <ContactList id="http://api.constantcontact.com/ws/customers/apisupport/lists/1">
                    <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/apisupport/lists/1"
                        rel="self"/>
                </ContactList>
            </ContactLists>
            <FromEmail>
                <Email
                    id="http://api.constantcontact.com/ws/customers/apisupport/settings/emailaddresses/1">
                    <link xmlns="http://www.w3.org/2005/Atom"
                        href="/ws/customers/apisupport/settings/emailaddresses/1" rel="self"/>
                </Email>
                <EmailAddress>bagnohax@gmail.com</EmailAddress>
            </FromEmail>
            <ReplyToEmail>
                <Email id="http://api.constantcontact.com/ws/customers/joesflowers/settings/emailaddresses/1">
                    <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/joesflowers/settings/emailaddresses/1"
                        rel="self" />
                </Email>
                <EmailAddress>joesflowers@example.com</EmailAddress>
            </ReplyToEmail>
        </Campaign>
    </content>
    <source>
        <id>http://api.constantcontact.com/ws/customers/a/campaigns</id>
        <title type="text">Campaigns</title>
        <link href="campaigns" rel="self"/>
        <author>
            <name>apisupport</name>
        </author>
        <updated>2011-11-02T18:37:06+01:00</updated>
    </source>
</entry>

 I think that this may resolve your issue but let me know if it does not.

Ryan Davis
Quality Engineer
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