400 Bad Request Error When Creating a new Campaign

Highlighted
Real Estate

400 Bad Request Error When Creating a new Campaign

Hello,  I am getting a 400 bad request error when trying to create a new campaign using your API.  Below is the XML file that I am sending for creation.  Is it possible for you to look and see what I am missing or messing up.  Let me know if I can provide any additional information.  Thanks.

 

?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
	<link href="/ws/customers/rmachiraju@mhinc.com/campaigns" rel="edit" />
	<id>http://api.constantcontact.com/ws/customers/rmachiraju@mhinc.com/campaigns</id>
	<title type="text">3005|Realtor Blast For Austin</title>
	<updated>2012-04-18T17:08:16.5938869-05:00</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/rmachiraju@mhinc.com/campaigns/0000000000000" >
			<Name>3005|Realtor Blast For Austin</Name>
			<Status>Draft</Status>
			<Date>2012-04-19T02:15:29.0000000</Date>
			<Subject>MHI Realtor Corner:  Quick Close Homes List and BTSA Information (Greater Austin Area)</Subject>
			<FromName>MHI Realtor Corner</FromName>
			<ViewAsWebpage>NO</ViewAsWebpage>
			<ViewAsWebpageLinkText/>
			<ViewAsWebpageText/>
			<PermissionReminder>NO</PermissionReminder>
			<PermissionReminderText/>
			<GreetingSalutation>Dear</GreetingSalutation>
			<GreetingString>Greetings!</GreetingString>
			<OrganizationName>McGuyer Homebuilders, Inc.</OrganizationName>
			<OrganizationAddress1>7676 Woodway Drive, Suite 104</OrganizationAddress1>
			<OrganizationAddress2/>
			<OrganizationAddress3/>
			<OrganizationCity>Houston</OrganizationCity>
			<OrganizationState>TX</OrganizationState>
			<OrganizationInternationalState/>
			<OrganizationCountry>us</OrganizationCountry>
			<OrganizationPostalCode>77063</OrganizationPostalCode>
			<IncludeForwardEmail>NO</IncludeForwardEmail>
			<ForwardEmailLinkText/>
			<IncludeSubscribeLink>NO</IncludeSubscribeLink>
			<SubscribeLinkText/>
			<GreetingName>First Name</GreetingName>
			<EmailContentFormat>HTML</EmailContentFormat>
			<EmailContent>&lt;!-- If your HTML code DOES include the html, head, and body tags,
replace the entire code below with your custom HTML code.

Please note, if you want to use the Constant Contact personalized greeting,
make sure to add the &lt;Greeting/&gt; tag to your code. --&gt;

&lt;html&gt;
&lt;body&gt;

&lt;!-- If your HTML code DOES NOT include the html, head, and body tags,
paste your custom HTML code between the START and END comments  --&gt;
&lt;!--    START    --&gt;
&lt;table cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; style=&quot;border: #000000 5px solid;
  font-size: 10pt; font-family: Verdana;  width:550px; margin-left:auto; margin-right:auto;&quot; align=&quot;center&quot;&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;a href=&quot;http://realtor.mhinc.com&quot; target=&quot;_blank&quot;&gt;
        &lt;img src=&quot;http://resources.mhinc.com/read/communications/templates/images/REAL_header.jpg&quot;
          style=&quot;width:100%; border: none;&quot; alt=&quot;MHI - Home of Plantation Homes, Coventry Homes, Pioneer Homes and Carmel Builders&quot; /&gt;&lt;/a&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
   &lt;tr&gt;
    &lt;td&gt;

        &lt;img src=&quot;http://resources.mhinc.com/read/notifications/images/homesreadynow_report_header_a.jpg&quot;
          style=&quot;width: 100%; border: none;&quot; alt=&quot;MHI - Home of Plantation Homes, Coventry Homes and Wilshire Homes&quot;  /&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;hr style=&quot;color:#c00;background-color:#c00;height:1px;border:none;&quot; /&gt;
    &lt;/td&gt; 
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td style=&quot;font-size: 10pt; font-family: Verdana;&quot;  width=&quot;100%&quot;&gt;
      &lt;Greeting/&gt;
      &lt;br /&gt;
      &lt;br /&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
	 &lt;img src=&quot;http://resources.mhinc.com/read/Notifications/3005/mytest.jpg&quot; alt=&quot;my test&quot; /&gt;                         
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td width=&quot;100%&quot;&gt;
       &lt;p style=&quot;font-size: 10pt; font-family: Verdana;&quot;&gt;
        Here is this week&#39;s list of &lt;a href=&quot;http://resources.mhinc.com/write/realtors/reports/h/HomesReadyNow.pdf&quot;&gt;quick close homes with 
          attractive BTSA&#39;s&lt;/a&gt;. We have an outstanding selection of homes ready for move-in
        plus great buyer incentives.
      &lt;/p&gt;
      &lt;p style=&quot;font-size: 10pt; font-family: Verdana;&quot;&gt;
        If you have not already, please register at our &lt;strong&gt;&lt;a href=&quot;http://realtor.mhinc.com&quot;&gt;
          Realtor Corner.&lt;/a&gt;&lt;/strong&gt; to get instant access to all our available inventory,
        BTSA&#39;s, quick-close homes, Realtor events, etc.
      &lt;/p&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &amp;nbsp;
    &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td style=&quot;font-size: 8pt; background-color: #A8A8A8;&quot; width=&quot;100%&quot;&gt;
      Do you have questions or messages for us? Here you will find an FAQ section and
      all the various ways of contacting us. &lt;a href=&quot;http://realtor.mhinc.com/contactus.aspx&quot;&gt;
        Help &amp; Contact&lt;/a&gt;
   &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td style=&quot;color: #A8A8A8; text-align: left; font-size: 7pt; margin-top: 10px;&quot; width=&quot;100%&quot;&gt;
      The information contained in this communication has not been reviewed by management
      for MHI Partnership, Ltd. (&amp;quot;MHI&amp;quot;) and may contain errors or misstatements. MHI
      does not represent or warrant that the information is presently accurate or complete.
      The recipient(s) of this information agree that they shall not act in reliance upon
      the information contained in this communication and hereby waive any claim, demand,
      cause of action or damage incurred as a result of the receipt of this communication.
      The information contained herein may be confidential or proprietary that is intended
      for the use of the addressee(s) only. If you are not the intended recipient of this
      communication, you are hereby notified that any dissemination or copying of this
      communication is strictly prohibited. If you have received this communication in
      error, please inform us promptly by return email, then delete and/or destroy the
      communication you received and destroy any printed copy(s). Thank you.
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;



&lt;!--     END     --&gt;
&lt;/body&gt;
&lt;/html&gt;</EmailContent>
			<EmailTextContent/>
			<StyleSheet/>
			<ContactLists>
				<ContactList id="http://api.constantcontact.com/ws/customers/rmachiraju@mhinc.com/lists/1">
					<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/rmachiraju@mhinc.com/lists/1" rel="self" />
				</ContactList>
			</ContactLists>
			<FromEmail>
				<Email id="http://api.constantcontact.com/ws/customers/rmachiraju@mhinc.com/settings/emailaddresses/2">
					<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/rmachiraju@mhinc.com/settings/emailaddresses/2" rel="self" />
				</Email>
				<EmailAddress>mhirealtorcorner@mhinc.com</EmailAddress>
			</FromEmail>
			<ReplyToEmail>
				<Email id="http://api.constantcontact.com/ws/customers/rmachiraju@mhinc.com/settings/emailaddresses/2">
					<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/rmachiraju@mhinc.com/settings/emailaddresses/2" rel="self" />
				</Email>
				<EmailAddress>mhirealtorcorner@mhinc.com</EmailAddress>
			</ReplyToEmail>
		</Campaign>
	</content>
	<source>
		<id>http://api.constantcontact.com/ws/customers/rmachiraju@mhinc.com/campaigns</id>
		<title type="text">Campaigns for customer: rmachiraju@mhinc.com</title>
		<link href="campaigns" />
		<link href="campaigns" rel="self" />
		<author>
			<name>rmachiraju@mhinc.com</name>
		</author>
		<updated>2012-04-18T17:08:18.9531789-05:00</updated>
	</source>
</entry>

 

 

4 REPLIES 4
Highlighted
Moderator

Re: 400 Bad Request Error When Creating a new Campaign

Hey, I'm noticing two errors that are causing the 400 in your XML. Your <GreetingName> tag has a value of "First Name", but the proper value does not have a space -- "FirstName". Also, the <EmailTextContent> tag can't be empty, you'll need to put in some sort of values, including opening and closing Text tags. I'd replace those fields like this:

 

<GreetingName>FirstName</GreetingName>
<EmailTextContent>&lt;Text>This is text content.&lt;/Text></EmailTextContent>

 

Nick Galbraith
Support Engineer
Highlighted
Real Estate

Re: 400 Bad Request Error When Creating a new Campaign

Perfect thank you.  It worked.   I was able to create a campaign.  It got created as "Draf".   What field should I be setting to Scheule the campaign?  I thought setting the <Date> would take care of it, but looks like not.   Should I be setting the NextRunDate instead.

Highlighted
Moderator

Re: 400 Bad Request Error When Creating a new Campaign

Have you requested scheduling permissions for your API key? If you haven't, we have a few questions we need to ask you, and we'll provide the documentation for scheduling. Just give us an email at webservices@constantcontact.com.

Nick Galbraith
Support Engineer
Highlighted
Real Estate

Re: 400 Bad Request Error When Creating a new Campaign

I don't recall if I did or not.  I will email webservices@constantcontact.com.

Developer Portal

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

Visit Page

Constant Contact Would Like To Hear From You!

We want to hear from customers like you about your favorite features and how they have helped your business or organization. Tell us by answering a few questions in...

Read More
Featured