Between 8:00 - 9:00 am ET on 10/25 we need to take our site down to make updates. We recommend logging out before 8:00am ET and not using your account during this time. Thank you for your patience while we make these important updates.

The remote server returned an error: (400) Bad Request - On Create Email Campaign

Occasional Participant

The remote server returned an error: (400) Bad Request - On Create Email Campaign

Hi,

 

I have downloded the code sample (NET_Sample_Campaign_Forms.zip) to create new Email Campaign from your forum.
In Web.Config I did the changes to add my user credentials and APIKey. When I ran the application and tried to Add Email Campaign, it returns the error as The remote server returned an error: (400) Bad Request.

Here is the xml content for Email campaign:

<?xml version='1.0' encoding='UTF-8'?><entry xmlns="http://www.w3.org/2005/Atom"><link href="/ws/customers/extentia.kmt/campaigns" rel="edit" /><id>http://api.constantcontact.com/ws/customers/extentia.kmt/campaigns</id><title type="text">Jul 13 2011</title><updated>2011-07-13T16:09:46.3316045+05:30</updated><author><name>Constant Contact</name></author><content type="application/vnd.ctct+xml"><Campaign xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/extentia.kmt/campaigns/0000000000000" ><Name>Jul 13 2011</Name><Status>Draft</Status><Date>2011-07-13T16:07:39.2855426+05:30</Date><Subject>News from</Subject><FromName>Suvarna</FromName><ViewAsWebpage>YES</ViewAsWebpage><ViewAsWebpageLinkText>Click here</ViewAsWebpageLinkText><ViewAsWebpageText>Having trouble viewing this email?</ViewAsWebpageText><PermissionReminder>YES</PermissionReminder><PermissionReminderText>You're receiving this email because of your relationship with extentia.kmt. Please confirm your continued interest in receiving email from us.</PermissionReminderText><GreetingSalutation></GreetingSalutation><GreetingName>FirstName</GreetingName><GreetingString></GreetingString><OrganizationName>Extentia</OrganizationName><OrganizationAddress1>Koregaon Park</OrganizationAddress1><OrganizationAddress2></OrganizationAddress2><OrganizationAddress3></OrganizationAddress3><OrganizationCity>Pune</OrganizationCity><OrganizationState></OrganizationState><OrganizationInternationalState></OrganizationInternationalState><OrganizationCountry>in</OrganizationCountry><OrganizationPostalCode>416001</OrganizationPostalCode><IncludeForwardEmail>YES</IncludeForwardEmail><ForwardEmailLinkText></ForwardEmailLinkText><IncludeSubscribeLink>YES</IncludeSubscribeLink><SubscribeLinkText></SubscribeLinkText><EmailContentFormat>HTML</EmailContentFormat><EmailContent>&lt;html lang=&quot;en&quot; xml:lang=&quot;en&quot; xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:cctd=&quot;http://www.constantcontact.com/cctd&quot;&gt;&lt;body&gt;&lt;CopyRight&gt;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 legal@constantcontact.com.&lt;/CopyRight&gt;&lt;OpenTracking/&gt;&lt;!--  Do NOT delete previous line if you want to get statistics on the number of opened emails --&gt;&lt;CustomBlock name=&quot;letter.intro&quot; title=&quot;Personalization&quot;&gt;&lt;Greeting/&gt;&lt;/CustomBlock&gt;&lt;/body&gt;&lt;/html&gt;</EmailContent><EmailTextContent>&lt;Text&gt;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 legal@constantcontact.com.&lt;/Text&gt;</EmailTextContent><StyleSheet></StyleSheet><ContactLists><ContactList id="http://api.constantcontact.com/ws/customers/extentia.kmt/lists/1"><link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/extentia.kmt/lists/1" rel="self" /></ContactList></ContactLists><FromEmail><Email id="http://api.constantcontact.com/ws/customers/extentia.kmt/settings/emailaddresses/1"><link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/extentia.kmt/settings/emailaddresses/1" rel="self" /></Email><EmailAddress>suvarna.gavali@gmail.com</EmailAddress></FromEmail><ReplyToEmail><Email id="http://api.constantcontact.com/ws/customers/extentia.kmt/settings/emailaddresses/1"><link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/extentia.kmt/settings/emailaddresses/1" rel="self" /></Email><EmailAddress>suvarna.gavali@gmail.com</EmailAddress></ReplyToEmail></Campaign></content><source><id>http://api.constantcontact.com/ws/customers/extentia.kmt/campaigns</id><title type="text">Campaigns for customer: extentia.kmt</title><link href="campaigns" /><link href="campaigns" rel="self" /><author><name>extentia.kmt</name></author><updated>2011-07-13T16:10:19.8313901+05:30</updated></source></entry>

Can you please have a look into it and let us know how it can be solved?

 

Thanks,

Suvarna

 

2 REPLIES 2
Employee

Hi Suvarna,

 

I went through your XML and noticed that you are enabling the Subscribe and forward links but you are not specifying what you want to have for the link text.  This code has been tested to work.

 

Spoiler
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
    <link href="/ws/customers/extentia.kmt/campaigns" rel="edit"/>
    <id>http://api.constantcontact.com/ws/customers/extentia.kmt/campaigns</id>
    <title type="text">Jul 13 2011</title>
    <updated>2011-07-13T16:09:46.3316045+05:30</updated>
    <author>
        <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
        <Campaign xmlns="http://ws.constantcontact.com/ns/1.0/"
            id="http://api.constantcontact.com/ws/customers/extentia.kmt/campaigns/0000000000000">
            <Name>Jul 13 2011</Name>
            <Status>Draft</Status>
            <Date>2011-07-13T16:07:39.2855426+05:30</Date>
            <Subject>News from</Subject>
            <FromName>Suvarna</FromName>
            <ViewAsWebpage>YES</ViewAsWebpage>
            <ViewAsWebpageLinkText>Click here</ViewAsWebpageLinkText>
            <ViewAsWebpageText>Having trouble viewing this email?</ViewAsWebpageText>
            <PermissionReminder>YES</PermissionReminder>
            <PermissionReminderText>You're receiving this email because of your relationship with
                extentia.kmt. Please confirm your continued interest in receiving email from
                us.</PermissionReminderText>
            <GreetingSalutation/>
            <GreetingName>FirstName</GreetingName>
            <GreetingString/>
            <OrganizationName>Extentia</OrganizationName>
            <OrganizationAddress1>Koregaon Park</OrganizationAddress1>
            <OrganizationAddress2/>
            <OrganizationAddress3/>
            <OrganizationCity>Pune</OrganizationCity>
            <OrganizationState/>
            <OrganizationInternationalState/>
            <OrganizationCountry>in</OrganizationCountry>
            <OrganizationPostalCode>416001</OrganizationPostalCode>
            <IncludeForwardEmail>YES</IncludeForwardEmail>
            <ForwardEmailLinkText>Forward</ForwardEmailLinkText>
            <IncludeSubscribeLink>YES</IncludeSubscribeLink>
            <SubscribeLinkText>Subscribe</SubscribeLinkText>
            <EmailContentFormat>HTML</EmailContentFormat>
            <EmailContent>&lt;html lang=&quot;en&quot; xml:lang=&quot;en&quot;
                xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
                xmlns:cctd=&quot;http://www.constantcontact.com/cctd&quot;&gt;&lt;body&gt;&lt;CopyRight&gt;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
                legal@constantcontact.com.&lt;/CopyRight&gt;&lt;OpenTracking/&gt;&lt;!-- Do NOT
                delete previous line if you want to get statistics on the number of opened emails
                --&gt;&lt;CustomBlock name=&quot;letter.intro&quot;
                title=&quot;Personalization&quot;&gt;&lt;Greeting/&gt;&lt;/CustomBlock&gt;&lt;/body&gt;&lt;/html&gt;</EmailContent>
            <EmailTextContent>&lt;Text&gt;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
                legal@constantcontact.com.&lt;/Text&gt;</EmailTextContent>
            <StyleSheet/>
            <ContactLists>
                <ContactList id="http://api.constantcontact.com/ws/customers/extentia.kmt/lists/1">
                    <link xmlns="http://www.w3.org/2005/Atom"
                        href="/ws/customers/extentia.kmt/lists/1" rel="self"/>
                </ContactList>
            </ContactLists>
            <FromEmail>
                <Email
                    id="http://api.constantcontact.com/ws/customers/extentia.kmt/settings/emailaddresses/1">
                    <link xmlns="http://www.w3.org/2005/Atom"
                        href="/ws/customers/extentia.kmt/settings/emailaddresses/1" rel="self"/>
                </Email>
                <EmailAddress>suvarna.gavali@gmail.com</EmailAddress>
            </FromEmail>
            <ReplyToEmail>
                <Email
                    id="http://api.constantcontact.com/ws/customers/extentia.kmt/settings/emailaddresses/1">
                    <link xmlns="http://www.w3.org/2005/Atom"
                        href="/ws/customers/extentia.kmt/settings/emailaddresses/1" rel="self"/>
                </Email>
                <EmailAddress>suvarna.gavali@gmail.com</EmailAddress>
            </ReplyToEmail>
        </Campaign>
    </content>
    <source>
        <id>http://api.constantcontact.com/ws/customers/extentia.kmt/campaigns</id>
        <title type="text">Campaigns for customer: extentia.kmt</title>
        <link href="campaigns"/>
        <link href="campaigns" rel="self"/>
        <author>
            <name>extentia.kmt</name>
        </author>
        <updated>2011-07-13T16:10:19.8313901+05:30</updated>
    </source>
</entry>

You can check out the documentation here and at the bottom of the page you will notice that if you have the option for the IncludeSubscribeLink set to YES then you must have a field for what text to display.  In the XML it is referenced as

Spoiler
            <IncludeForwardEmail>YES</IncludeForwardEmail>
            <ForwardEmailLinkText>Forward</ForwardEmailLinkText>
            <IncludeSubscribeLink>YES</IncludeSubscribeLink>
            <SubscribeLinkText>Subscribe</SubscribeLinkText>

 If you have any other questions please let me know.

 

Regards,

Ryan Davis
Quality Engineer
Occasional Participant

Hi Ryan,

 

Thanks.. It solved the issue.

 

Suvarna

Developer Portal

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

Visit Page