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.

Creating Campaign using JAVA giving : Response status :HTTP/1.1 400 Bad Request

SOLVED
Go to solution
Highlighted
Occasional Contributor

Re: Creating Campaign using JAVA giving : Response status :HTTP/1.1 400 Bad Request

I am using multiple contacts in the campaigns I am scheduling. In the emails Content I need to put the details Names of the person who ever is receiving the Campaign email.

 

Eg In a campaign there are two contacts

     1, x@yyyy.com (First Name xxxx, Last Name yyyyy)

     2. b@abc.com(First Name AAAAA, Last Name BBBB)

 

I am creating contactList with the contacts

 

When the email is received by the receiver he/she should have the email contant as Dear <First Name> <Last Name>

 

I am able to send a standard format to all the contact mentioned in the campaign.

 

I there a way to personalize the email content based on the contacts?

 

 

 

Highlighted
Moderator

Re: Creating Campaign using JAVA giving : Response status :HTTP/1.1 400 Bad Request

If you're using one of our standard templates through our editor, you can find out how to add personalization here: http://constantcontact.custhelp.com/app/answers/detail/a_id/2069/kw/insert%20contact%20detail/r_id/1...

 

If you're using your own custom HTML code, it's a bit more complicated since you'll have to use XHTML merge tags.  We have a great guide to these advanced features here: http://img.constantcontact.com/docs/pdf/building-your-emails-with-the-advanced-editor-tool-constant-...

Dave Berard
Senior Product Manager, Constant Contact
Highlighted
Occasional Contributor

Re: Creating Campaign using JAVA giving : Response status :HTTP/1.1 400 Bad Request

I have tried to customise the email content in a email campaign as below. but I have not find the firstName of the contact in the email content. Please let me know what updations I need to do for the request

 

I have added the FirstName and LastName attributes to the contact used in this campaign

 

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<link href="/ws/customers/[removed my moderator]/campaigns" rel="edit"/>
<id>http://api.constantcontact.com/ws/customers/[removed my moderator]/campaigns</id>
<title type="text">API Test r Email 2012-08-14T14:44:49.970Z</title>
<updated>2012-08-14T14:44:49.970Z</updated>
<author>
<name>Constant </name>
</author>
<content type="application/vnd.ctct+xml">
<Campaign xmlns="http://ws.constantcontact.com/ns/1.0/"
id="http://api.constantcontact.com/ws/customers/[removed my moderator]
/campaigns/1111122233">
<Name>ShipcarsNow CTCT Campaign 2012-08-14T14:44:49.970Z</Name>
<Status>Draft</Status>
<Date>2012-08-14T14:44:49.970Z</Date>
<Subject>ShipCarsNow Test</Subject>
<FromName>ShipCarsNow Test</FromName>
<ViewAsWebpage>NO</ViewAsWebpage>
<ViewAsWebpageLinkText/>
<ViewAsWebpageText/>
<PermissionReminder>YES</PermissionReminder>
<PermissionReminderText>
You're receiving this email because of your relationship with ctct. Please
&lt;ConfirmOptin>&lt;a style="color:#0000ff;">confirm&lt;/a>&lt;/ConfirmOptin>
your continued interest in receiving email from us.
</PermissionReminderText>
<GreetingSalutation>Dear</GreetingSalutation>
<GreetingName>FirstName</GreetingName>
<GreetingString>Greetings!</GreetingString>
<OrganizationName>ShipCarsnow</OrganizationName>
<OrganizationAddress1>123 wsw st</OrganizationAddress1>
<OrganizationAddress2/>
<OrganizationAddress3/>
<OrganizationCity>OMAHA</OrganizationCity>
<OrganizationState>NE</OrganizationState>
<OrganizationInternationalState/>
<OrganizationCountry>US</OrganizationCountry>
<OrganizationPostalCode>32423</OrganizationPostalCode>
<IncludeForwardEmail>NO</IncludeForwardEmail>
<ForwardEmailLinkText/>
<IncludeSubscribeLink>NO</IncludeSubscribeLink>
<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 topmargin=&quot;0&quot; leftmargin=&quot;0&quot; rightmargin=&quot;0&quot;&gt;
  &lt;Greeting /&gt;
  &lt;br /&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 [removed my moderator].
    &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;Greeting /&gt;
  &lt;CustomBlock name=&quot;letter.intro&quot; title=&quot;Personalization&quot;&gt;
   &lt;table style=&quot;background-color:#FFFFFF;&quot; bgcolor=&quot;#FFFFFF&quot;
    border=&quot;0&quot; width=&quot;100%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;1&quot;&gt;
    &lt;tr&gt;
    &lt;td width=&quot;100%&quot;  rowspan=&quot;1&quot; colspan=&quot;1&quot; align=&quot;center&quot;&gt;
    &lt;table style=&quot;width:600px;&quot; border=&quot;0&quot; width=&quot;100%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;    
    &lt;/table&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
    &lt;td rowspan=&quot;1&quot; colspan=&quot;1&quot; align=&quot;center&quot;&gt;
    &lt;table style=&quot;width:600px;border-color:#E4E4E4;border-width:1px;border-style:solid;&quot;
     border=&quot;0&quot; bordercolor=&quot;#E4E4E4&quot; width=&quot;600&quot; cellspacing=&quot;0&quot;
     cellpadding=&quot;0&quot;&gt;
    &lt;tr&gt;
    &lt;td width=&quot;100%&quot; rowspan=&quot;1&quot; colspan=&quot;1&quot;&gt;
    
    &lt;table border=&quot;0&quot; width=&quot;100%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot; id=&quot;content_LETTER.BLOCK3&quot;&gt;
    &lt;tr&gt;
    &lt;td style=&quot;color:#555555;font-family:Arial,Helvetica,sans-serif;font-size:10pt;text-align: left;&quot;
     rowspan=&quot;1&quot; colspan=&quot;1&quot; align=&quot;left&quot;&gt;
    &lt;b&gt;Dear Customer,&lt;Greeting /&gt;&lt;/b&gt;
    &lt;br /&gt;
    &lt;br /&gt;    
    &lt;div&gt;
    &lt;p&gt;
    As an important customer of ShipCarsNow, we would appreciate it if you would take a few minutes to answer 10 brief questions
    about your satisfaction with our service over the past year. We will use your feedback to improve our auto transport service
    and products to better serve you and your company.
    &lt;/p&gt;
    &lt;/div&gt;    
    &lt;div style=&quot;text-align: center;&quot; align=&quot;center&quot;&gt;
    &lt;b&gt;
    &lt;p&gt;
    &lt;a style=&quot;font-family: Arial, Helvetica, sans-serif; letter-spacing: -3px; color: #ff0000; font-size: 24pt; text-decoration: underline;&quot;
       href=&quot;http://survey.constantcontact.com/survey/a07e5ou49kegzk6shgq/start&quot;&gt;Take this survey
      &lt;/a&gt;
      &lt;/p&gt;
      &lt;/b&gt;
      &lt;/div&gt;
      &lt;div&gt;
      &lt;/div&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td width=&quot;100%&quot; rowspan=&quot;1&quot; colspan=&quot;1&quot;&gt;
      &lt;table border=&quot;0&quot; width=&quot;100%&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;&gt;
      &lt;tr&gt;
    &lt;td style=&quot;color:#555555;font-family:Arial,Helvetica,sans-serif;font-size:10pt;&quot;
        rowspan=&quot;1&quot; colspan=&quot;1&quot; align=&quot;left&quot;&gt;
     &lt;p&gt;Thank you for trusting your car with us!  We appreciate your participation in our survey and hope you will consider
     ShipCarsNow the next time you or someone you know needs to ship a car.
     &lt;/p&gt;
    &lt;div&gt;
   &lt;/div&gt;
   &lt;div&gt;Sincerely,
   &lt;/div&gt;   
   &lt;br/&gt; Jeff Grandstaff
   &lt;br/&gt; General Manager
   &lt;br/&gt; 1-866-207-3360
      
   &lt;br/&gt; &lt;a href=&quot;http://www.shipcarsnow.com&quot;&gt;www.shipcarsnow.com&lt;/a&gt;
   
   &lt;p&gt; Need another auto transport quote? &lt;a href=&quot;https://www.shipcarsnow.com/Residential-Auto-Shipping/why-choose-shipcarsnow.html&quot;&gt;Click here for your Free Quote!&lt;/a&gt;
   &lt;/p&gt;
   &lt;p&gt;
   PS ... Tell your favorite car dealer to put ShipCarsNow shipping quotes on their website! Our new
   
   &lt;a href=&quot;http://www.shipcarsnow.com/news/shipcarsnow-extends-dealer-services.html&quot;&gt;ConnectNOW program&lt;/a&gt;
   for dealers makes it easy.
   &lt;/p&gt;
   &lt;br/&gt; &lt;img border=&quot;0&quot; src=&quot;https://imgssl.constantcontact.com/ui/images1/btn_fbk_160_a.png&quot; /&gt;
      
   &lt;/td&gt;
   &lt;/tr&gt;
   &lt;/table&gt;
   &lt;/td&gt;
   &lt;/tr&gt;
   &lt;/table&gt;
   &lt;/td&gt;
   &lt;/tr&gt;
   &lt;/table&gt;
   &lt;/CustomBlock&gt;
   &lt;/body&gt;
   &lt;/html&gt;
</EmailContent>
<EmailTextContent>
&lt;Text>This is the text version.&lt;/Text>
</EmailTextContent>
<StyleSheet/>
<ContactLists>
<ContactList
id="http://api.constantcontact.com/ws/customers/[removed my moderator]/lists/693">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/[removed my moderator]/lists/693"
rel="self"/>
</ContactList>
</ContactLists>
<FromEmail>
<Email
id="http://api.constantcontact.com/ws/customers/[removed my moderator]/settings/emailaddresses/8">
<link xmlns="http://www.w3.org/2005/Atom"
href="/ws/customers/[removed my moderator]/settings/emailaddresses/8" rel="self"/>
</Email>
<EmailAddress>[removed my moderator]</EmailAddress>
</FromEmail>
<ReplyToEmail>
<Email
id="http://api.constantcontact.com/ws/customers/[removed my moderator]/settings/emailaddresses/8">
<link xmlns="http://www.w3.org/2005/Atom"
href="/ws/customers/[removed my moderator]/settings/emailaddresses/8" rel="self"/>
</Email>
<EmailAddress>[removed my moderator]</EmailAddress>
</ReplyToEmail>
</Campaign>
</content>
<source>
<id>http://api.constantcontact.com/ws/customers/[removed my moderator]/campaigns
</id>
<title type="text">Campaigns for customer: [removed my moderator]</title>
<link href="campaigns"/>
<link href="campaigns" rel="self"/>
<author>
<name>[removed my moderator]</name>
</author>
<updated>2009-10-21T19:36:12.622Z</updated>
</source>
</entry>

Highlighted
Employee

Re: Creating Campaign using JAVA giving : Response status :HTTP/1.1 400 Bad Request

Hi,

 

It looks like you're using HTML as your email type, but trying to pull contact details.  Unfortunately, our system only lets you pull contact details from the account if you're using XHTML as the email type. 

 

This link explains a little more about how to pull contact details with an XHTML email, though it does look like you're doing that correctly, taking a quick glance at your code.

 

I hope that helps!

 

Regards,

Shannon W.

API Support

 

 

Highlighted
Trusted Contributor

Re: Creating Campaign using JAVA giving : Response status :HTTP/1.1 400 Bad Request

Hello,

 

I've edited your post to remove any private information (email addressed, account credentials) for your security.

Mark Coleman
Support Engineer
Highlighted
Occasional Contributor

Re: Creating Campaign using JAVA giving : Response status :HTTP/1.1 400 Bad Request

Hi,

 

I have used the following format of requestt xml and able to create campaign a couple of days back. but now its giving 400 error again. Please let me know if there is any chnages to do?

 

 

<?xml version="1.0" encoding="UTF-8"?>

<entry xmlns="http://www.w3.org/2005/Atom">

<link href="/ws/customers/shipcarsnow1/campaigns" rel="edit"/>

<id>http://api.constantcontact.com/ws/customers/shipca​rsnow1/campaigns</id>

<title type="text">API Test Email</title>

<updated>2012-05-21T18:34:53.105Z</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/shipca​rsnow1/campaigns/1111122233">

<Name>API Test Email</Name>

<Status>Draft</Status>

<Date>2009-10-19T18:34:53.105Z</Date>

<Subject>ShipCarsNow Test</Subject>

<FromName>ShipCarsNow Test</FromName>

<ViewAsWebpage>NO</ViewAsWebpage>

<ViewAsWebpageLinkText/>

<ViewAsWebpageText/>

<PermissionReminder>YES</PermissionReminder>

<PermissionReminderText>

You're receiving this email because of your relationship with ctct.

Please

&lt;ConfirmOptin>

&lt;a style="color:#0000ff;">confirm&lt;/a>

&lt;/ConfirmOptin>

your continued interest in receiving email from us.

&lt;/PermissionReminderText>

<GreetingSalutation>Dear</GreetingSalutation>

<GreetingName>FirstName</GreetingName>

<GreetingString>Greetings!</GreetingString>

<OrganizationName>ShipCarsnow</OrganizationName>

<OrganizationAddress1>123 wsw st</OrganizationAddress1>

<OrganizationAddress2/>

<OrganizationAddress3/>

<OrganizationCity>OMAHA</OrganizationCity>

<OrganizationState>NE</OrganizationState>

<OrganizationInternationalState/>

<OrganizationCountry>US</OrganizationCountry>

<OrganizationPostalCode>32423</OrganizationPostalC​ode>

<IncludeForwardEmail>NO</IncludeForwardEmail>

<ForwardEmailLinkText/>

<IncludeSubscribeLink>NO</IncludeSubscribeLink>

<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 slboucher@shipcarsnow.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>This is the text version.&lt;/Text>

</EmailTextContent>

<StyleSheet/>

<ContactLists>

<ContactList

id="http://api.constantcontact.com/ws/customers/shipca​rsnow1/lists/170">

<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/shipcarsnow1/lists/170"

rel="self"/>

</ContactList>

</ContactLists>

<FromEmail>

<Email

id="http://api.constantcontact.com/ws/customers/shipca​rsnow1/settings/emailaddresses/8">

<link xmlns="http://www.w3.org/2005/Atom"

href="/ws/customers/shipcarsnow1/settings/emailadd​resses/8" rel="self"/>

</Email>

<EmailAddress>slboucher@shipcarsnow.com</EmailAddr​ess>

</FromEmail>

<ReplyToEmail>

<Email

id="http://api.constantcontact.com/ws/customers/shipca​rsnow1/settings/emailaddresses/8">

<link xmlns="http://www.w3.org/2005/Atom"

href="/ws/customers/shipcarsnow1/settings/emailadd​resses/8" rel="self"/>

</Email>

<EmailAddress>slboucher@shipcarsnow.com</EmailAddr​ess>

</ReplyToEmail>

</Campaign>

</content>

<source>

<id>http://api.constantcontact.com/ws/customers/shipca​rsnow1/campaigns

</id>

<title type="text">Campaigns for customer: shipcarsnow1</title>

<link href="campaigns"/>

<link href="campaigns" rel="self"/>

<author>

<name>shipcarsnow1</name>

</author>

<updated>2009-10-19T19:36:12.622Z</updated>

</source>

</entry>

 

 

Highlighted
Moderator

Re: Creating Campaign using JAVA giving : Response status :HTTP/1.1 400 Bad Request

I'm noticing two problems with this XML. We're seeing the recurring set of characters "​" in the middle of the username throughout the code. This might represent some sort of non-space character, or something else of the sort, or it could just be a pasting error into this system.

 

The other issue I've found is with the permission reminder line. It currently reads as this:

<PermissionReminderText>
You're receiving this email because of your relationship with ctct.
Please &lt;ConfirmOptin>&lt;a style="color:#0000ff;">confirm&lt;/a>&lt;/ConfirmOptin>your continued interest in receiving email from us.
&lt;/PermissionReminderText>

 The &lt;'s are in the right place, until you reach the PermissionReminderText tag, which needs to have the actual "<" symbol. When I corrected this error in the code, the campaign was created successfully in my account.

<PermissionReminderText>
You're receiving this email because of your relationship with ctct. Please &lt;ConfirmOptin>&lt;a style="color:#0000ff;">confirm&lt;/a>&lt;/ConfirmOptin> your continued interest in receiving email from us.
</PermissionReminderText>

 

Nick Galbraith
Support 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