Creating Campaigns 400 error.

RachelE81
Frequent Participant

Creating Campaigns 400 error.

No idea what is causing this. Here is my code.

 

string

XMLData = "";

                XMLData +=

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

                XMLData +=

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

                XMLData +=

"<link href=\"/ws/customers/smimarketing/campaigns\" rel=\"edit\" />";

                XMLData +=

"<id>http://api.constantcontact.com/ws/customers/smimarketing/campaigns</id>";

                XMLData +=

"<title type=\"text\">Test Email</title>";

                XMLData +=

"<updated>2011-10-30T19:34:53.105Z</updated>";

                XMLData +=

"<author>";

                XMLData +=

"<name>Constant Contact</name>";

                XMLData +=

"</author>";

                XMLData +=

"<content type=\"application/vnd.ctct+xml\">";

                XMLData +=

"<Campaign xmlns=\"http://ws.constantcontact.com/ns/1.0/\" id=\"http://api.constantcontact.com/ws/customers/smimarketing/campaigns/3\">";

               

                XMLData +=

"<Name>API Test Email</Name>";

                XMLData +=

"<Status>Draft</Status>";

                XMLData +=

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

                XMLData +=

"<Subject>Test Email</Subject>";

                XMLData +=

"<FromName>smi@strategicmarketing.com</FromName>";

                XMLData +=

"<ViewAsWebpage>NO</ViewAsWebpage>";

                XMLData +=

"<ViewAsWebpageLinkText></ViewAsWebpageLinkText>";

                XMLData +=

"<ViewAsWebpageText></ViewAsWebpageText>";

                XMLData +=

"<PermissionReminder>NO</PermissionReminder>";

                XMLData +=

"<PermissionReminderText></PermissionReminderText>";

                XMLData +=

"<GreetingSalutation>Dear</GreetingSalutation>";

                XMLData +=

"<GreetingName>FirstName</GreetingName>";

                XMLData +=

"<GreetingString>Greetings!</GreetingString>";

                XMLData +=

"<OrganizationName>ctct</OrganizationName>";

                XMLData +=

"<OrganizationAddress1>123 wsw st</OrganizationAddress1>";

                XMLData +=

"<OrganizationAddress2></OrganizationAddress2>";

                XMLData +=

"<OrganizationAddress3></OrganizationAddress3>";

                XMLData +=

"<OrganizationCity>Ashland</OrganizationCity>";

                XMLData +=

"<OrganizationState>MA</OrganizationState>";

                XMLData +=

"<OrganizationInternationalState></OrganizationInternationalState>";

                XMLData +=

"<OrganizationCountry>us</OrganizationCountry>";

                XMLData +=

"OrganizationPostalCode>32423</OrganizationPostalCode>";

                XMLData +=

"<IncludeForwardEmail>NO</IncludeForwardEmail>";

                XMLData +=

"<ForwardEmailLinkText></ForwardEmailLinkText>";

                XMLData +=

"<IncludeSubscribeLink>NO</IncludeSubscribeLink>";

                XMLData +=

"<SubscribeLinkText></SubscribeLinkText>";

                XMLData +=

"<EmailContentFormat>HTML</EmailContentFormat>";

                XMLData +=

"<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 aseparatewritten agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on anyConstant Contact site,including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, ordistributed without theprior written permission of Constant Contact.  For inquiries regarding reproduction or distribution of any ConstantContact material, pleasecontact 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>";

                XMLData +=

"<EmailTextContent>&lt;Text>This is the text version.&lt;/Text></EmailTextContent>";

                XMLData +=

"<StyleSheet></StyleSheet>";

                XMLData +=

"<ContactLists>";

                XMLData +=

"<ContactList id=\"http://api.constantcontact.com/ws/customers/smimarketing/lists/1\"><link xmlns=\"http://www.w3.org/2005/Atom\" href=\"/ws/customers/smimarketing/lists/1\" rel=\"self\"/></ContactList>";

                XMLData +=

"</ContactLists>";

                XMLData +=

"<FromEmail>";

                XMLData +=

"<Email id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/1\"><link xmlns=\"http://www.w3.org/2005/Atom\" href=\"/ws/customers/smimarketing/settings/emailaddresses/1\" rel=\"self\"/></Email>";

                XMLData +=

"<EmailAddress>me@me.com</EmailAddress>";

                XMLData +=

"</FromEmail>";

                XMLData +=

"<ReplyToEmail>";

                XMLData +=

"<Email id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/1\"><link xmlns=\"http://www.w3.org/2005/Atom\" href=\"/ws/customers/smimarketing/settings/emailaddresses/1\" rel=\"self\" /></Email>";

                XMLData +=

"<EmailAddress>me@me.com</EmailAddress>";

                XMLData +=

"</ReplyToEmail>";

                XMLData +=

"</Campaign>";

                XMLData +=

"</content>";

                XMLData +=

"<source>";

                XMLData +=

"<id>http://api.constantcontact.com/ws/customers/smimarketing/campaigns</id>";

                XMLData +=

"<title type=\"text\">Campaigns for customer: smimarketing</title>";

                XMLData +=

"<link href=\"campaigns\" />";

                XMLData +=

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

                XMLData +=

"<author>";

                XMLData +=

"<name>smimarketing</name>";

                XMLData +=

"</author>";

                XMLData +=

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

                XMLData +=

"</source>";

                XMLData +=

"</entry>";

               

byte[] byteArray = Encoding.UTF8.GetBytes(XMLData);

               

CredentialCache LoginCredentials = newCredentialCache();

               

string ContactURI = String.Format("https://api.constantcontact.com/ws/customers/{0}/{1}", API_USERNAME, API_RESOURCE_CAMPAIGNS);

                LoginCredentials.Add(

newUri(@"https://api.constantcontact.com/ws/customers/smimarketing"), "Basic", newNetworkCredential(API_KEY + @"%" + API_USERNAME, API_PASSWORD));

 

               

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ContactURI);

                request.Credentials = LoginCredentials;

                request.Method =

"POST";

                request.ContentType =

@"application/atom+xml";

                request.ContentLength = byteArray.Length;

               

Stream dataStream = request.GetRequestStream();

                dataStream.Write(byteArray, 0, byteArray.Length);

                dataStream.Close();

               

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

               

string returnString = response.StatusCode.ToString();

15 REPLIES 15
DaveBerard
Moderator

Couple questions Rachel.  Is this your exact unmodified code?   If so, it is likely that the email address that you're using in the FromEmail and ReplyEmail is not a verified email address in your account (I looked it up and noticed you have two verified addresses, neither of which is me@me.com).  If you obfuscated the email address for posting here, please ignore that point and let me know if that's the case.

 

Did you use a try/catch block to catch the WebException and then use the WebException.Response property to read the full response message?  We send back a full response body that will often times give you the exact cause of the 400 error in the full body.  That could give us guidance on the problem. 

 

We will be able to get back to you later after running your code locally against an account internally and trying to track down there error here, should have more information early this afternoon.

Dave Berard
Senior Product Manager, Constant Contact
RachelE81
Frequent Participant

Whoa thanks Dave.  This was exact :( so I will be looking for these verified email addresses.  Any idea on how i could find those quickly?

 

All verified email addresses are part of the EmailSettings collectoin.  You can do a GET request against it to pull all the verified addresses and then allow the user to pick from a list of the available addresses for the FromEmail and ReplyEmail.  You can find documentation on that collection here: http://community.constantcontact.com/t5/Documentation/Account-Email-Addresses-Collection/ba-p/25091

Dave Berard
Senior Product Manager, Constant Contact
RachelE81
Frequent Participant

Ok so I have changed the emails to the correct ones?  I am still getting the error.  I am debugging it and trying to get the WebExcepiton response but i do not know exactly what I am looking for?  Also was I suppose to GET the id's for the 2 verified addresses or just use them in the *********@*******.com form

 

Thanks dave

You will need to update the entire ReplyEmail and FromEmail XML with the full information that you pulled from the EmailAddress Collection.  When you're catching the WebException error, here is some code you can use to pull the full error response message and see what the exact error message is that we return:

 

           

catch (WebException ex)

{

               StreamReader reader = new StreamReader(ex.Response.GetResponseStream());

               String responseBody = reader.ReadToEnd();

               String responseCode = ((HttpWebResponse)ex.Response).StatusCode;

}

Dave Berard
Senior Product Manager, Constant Contact
RachelE81
Frequent Participant

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses</id>
  <title type="text"></title>
  <link href="emailaddresses"></link>
  <link href="emailaddresses" rel="self"></link>
  <author>
    <name>smimarketing</name>
  </author>
  <updated>2011-11-01T15:09:48.979Z</updated>
  <entry>
    <link href="/ws/customers/smimarketing/settings/emailaddresses/1" rel="edit"></link>
    <id>http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/1</id>
    <title type="text">rachel@strategicmarketing.com</title>
    <updated>2011-09-13T20:38:09.045Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <Email xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/1">
        <EmailAddress>rachel@strategicmarketing.com</EmailAddress>
        <Status>Verified</Status>
        <VerifiedTime>2011-09-13T20:38:09.045Z</VerifiedTime>
      </Email>
    </content>
  </entry>
  <entry>
    <link href="/ws/customers/smimarketing/settings/emailaddresses/2" rel="edit"></link>
    <id>http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/2</id>
    <title type="text">tom@strategicmarketing.com</title>
    <updated>2011-09-27T20:03:25.424Z</updated>
    <author>
      <name>Constant Contact</name>
    </author>
    <content type="application/vnd.ctct+xml">
      <Email xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/2">
        <EmailAddress>tom@strategicmarketing.com</EmailAddress>
        <Status>Verified</Status>
        <VerifiedTime>2011-09-27T20:03:25.424Z</VerifiedTime>
      </Email>
    </content>
  </entry>
</feed>

 

 

Using the RESTClient this is what i get.  So i just replace rachel@smimarketing.com and tom@smimarketing.com for the campaign XML... I dont fully understand what you mean by "update the entire ReplyEmail and FromEmail XML with the full information that you pulled."

If you notice you received multiple <entry> nodes with the response XML that have details on each verified email address.  Here is the code you are correctly using to set the FromEmail, you'll want to pull the information from the XML you just received and use that to correctly populate the related fields.  You'll see that they map up directly with the same named fields and nodes from the XML you posted above. 

 

 XMLData += "<FromEmail>";

XMLData += "<Email id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/1\"><link xmlns=\"http://www.w3.org/2005/Atom\" href=\"/ws/customers/smimarketing/settings/emailaddresses/1\" rel=\"self\"/></Email>";

XMLData += "<EmailAddress>me@me.com</EmailAddress>";

XMLData += "</FromEmail>";

Dave Berard
Senior Product Manager, Constant Contact
RachelE81
Frequent Participant

Ok thankyou then.

 

when i get the email node i get it back like this

 

<Email xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/2">
        <EmailAddress>tom@strategicmarketing.com</EmailAddress>
        <Status>Verified</Status>
        <VerifiedTime>2011-09-27T20:03:25.424Z</VerifiedTime>
      </Email>

 

<Email xmlns=\"http://ws.constantcontact.com/ns/1.0/\" id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/2\"><EmailAddress>tom@strategicmarketing.com</EmailAddress><Status>Verified</Status><VerifiedTime>2011-09-27T20:03:25.424Z</VerifiedTime></Email>";

 

i do not know which one of these is the correct one to use.  But both methods on email 1 and 2 do not work i get this message now using the catch.

 

Error 400: The request contains errors in the common Atom sections, which lie outside <entry> or <Content>, such as <feed>, <id>, <author> or <updated>.

 

 

RachelE81
Frequent Participant

sorry this is the other one i was using

 

XMLData += "<Email id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/2\"><link xmlns=\"http://www.w3.org/2005/Atom\" href=\"/ws/customers/smimarketing/settings/emailaddresses/2\" rel=\"self\" /></Email>";

 

Could you post the final XML you are generating before the POST request?  The error indicates that there is an error in the Campaign XML and will need some troubleshooting.  If you don't want to post personal information on the forum, please email webservices@constantcontact.com instead with your XML in a text file (Do not include it in the body of the response as it is likely to be filtered out by).

Dave Berard
Senior Product Manager, Constant Contact
RachelE81
Frequent Participant

private

void btn_CampaignSubmit_Click(object sender, EventArgs e)

        {

           

try


            {

 

               

string XMLData = "";

XMLData +=

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

                XMLData +=

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

                XMLData +=

"<link href=\"/ws/customers/smimarketing/campaigns\" rel=\"edit\" />";

                XMLData +=

"<id>http://api.constantcontact.com/ws/customers/smimarketing/campaigns</id>";

                XMLData +=

"<title type=\"text\">Test Email</title>";

                XMLData +=

"<updated>2011-10-30T19:34:53.105Z</updated>";

                XMLData +=

"<author>";

                XMLData +=

"<name>Constant Contact</name>";

                XMLData +=

"</author>";

                XMLData +=

"<content type=\"application/vnd.ctct+xml\">";

                XMLData +=

"<Campaign xmlns=\"http://ws.constantcontact.com/ns/1.0/\" id=\"http://api.constantcontact.com/ws/customers/smimarketing/campaigns/3\">";

                XMLData +=

"<Name>API Test Email</Name>";

                XMLData +=

"<Status>Draft</Status>";

                XMLData +=

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

                XMLData +=

"<Subject>Test Email</Subject>";

                XMLData +=

"<FromName>smi@strategicmarketing.com</FromName>";

                XMLData +=

"<ViewAsWebpage>NO</ViewAsWebpage>";

                XMLData +=

"<ViewAsWebpageLinkText></ViewAsWebpageLinkText>";

                XMLData +=

"<ViewAsWebpageText></ViewAsWebpageText>";

                XMLData +=

"<PermissionReminder>NO</PermissionReminder>";

                XMLData +=

"<PermissionReminderText></PermissionReminderText>";

                XMLData +=

"<GreetingSalutation>Dear</GreetingSalutation>";

                XMLData +=

"<GreetingName>FirstName</GreetingName>";

                XMLData +=

"<GreetingString>Greetings!</GreetingString>";

                XMLData +=

"<OrganizationName>ctct</OrganizationName>";

                XMLData +=

"<OrganizationAddress1>123 wsw st</OrganizationAddress1>";

                XMLData +=

"<OrganizationAddress2></OrganizationAddress2>";

                XMLData +=

"<OrganizationAddress3></OrganizationAddress3>";

                XMLData +=

"<OrganizationCity>Ashland</OrganizationCity>";

                XMLData +=

"<OrganizationState>MA</OrganizationState>";

                XMLData +=

"<OrganizationInternationalState></OrganizationInternationalState>";

                XMLData +=

"<OrganizationCountry>us</OrganizationCountry>";

                XMLData +=

"OrganizationPostalCode>32423</OrganizationPostalCode>";

                XMLData +=

"<IncludeForwardEmail>NO</IncludeForwardEmail>";

                XMLData +=

"<ForwardEmailLinkText></ForwardEmailLinkText>";

                XMLData +=

"<IncludeSubscribeLink>NO</IncludeSubscribeLink>";

                XMLData +=

"<SubscribeLinkText></SubscribeLinkText>";

                XMLData +=

"<EmailContentFormat>HTML</EmailContentFormat>";

                XMLData +=

"<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 aseparatewritten agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on anyConstant Contact site,including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, ordistributed without theprior written permission of Constant Contact.  For inquiries regarding reproduction or distribution of any ConstantContact material, pleasecontact 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>";

                XMLData +=

"<EmailTextContent>&lt;Text>This is the text version.&lt;/Text></EmailTextContent>";

                XMLData +=

"<StyleSheet></StyleSheet>";

                XMLData +=

"<ContactLists>";

                XMLData +=

"<ContactList id=\"http://api.constantcontact.com/ws/customers/smimarketing/lists/1\"><link xmlns=\"http://www.w3.org/2005/Atom\" href=\"/ws/customers/smimarketing/lists/1\" rel=\"self\"/></ContactList>";

                XMLData +=

"</ContactLists>";

                XMLData +=

"<FromEmail>";

               

//XMLData += "<Email id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/1\"><link xmlns=\"http://www.w3.org/2005/Atom\" href=\"/ws/customers/smimarketing/settings/emailaddresses/1\" rel=\"self\"/></Email>";


                XMLData +=

"<Email xmlns=\"http://ws.constantcontact.com/ns/1.0/\" id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/1\"><EmailAddress>rachel@strategicmarketing.com</EmailAddress><Status>Verified</Status><VerifiedTime>2011-09-13T20:38:09.045Z</VerifiedTime></Email>";

                XMLData +=

"<EmailAddress>rachel@strategicmarketing.com</EmailAddress>";

                XMLData +=

"</FromEmail>";

                XMLData +=

"<ReplyToEmail>";

                XMLData +=

"<Email xmlns=\"http://ws.constantcontact.com/ns/1.0/\" id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/2\"><EmailAddress>tom@strategicmarketing.com</EmailAddress><Status>Verified</Status><VerifiedTime>2011-09-27T20:03:25.424Z</VerifiedTime></Email>";

               

//XMLData += "<Email id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/2\"><link xmlns=\"http://www.w3.org/2005/Atom\" href=\"/ws/customers/smimarketing/settings/emailaddresses/2\" rel=\"self\" /></Email>";


                XMLData +=

"<EmailAddress>tom@strategicmarketing.com</EmailAddress>";

                XMLData +=

"</ReplyToEmail>";

                XMLData +=

"</Campaign>";

                XMLData +=

"</content>";

                XMLData +=

"<source>";

                XMLData +=

"<id>http://api.constantcontact.com/ws/customers/smimarketing/campaigns</id>";

                XMLData +=

"<title type=\"text\">Campaigns for customer: smimarketing</title>";

                XMLData +=

"<link href=\"campaigns\" />";

                XMLData +=

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

                XMLData +=

"<author>";

                XMLData +=

"<name>smimarketing</name>";

                XMLData +=

"</author>";

                XMLData +=

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

                XMLData +=

"</source>";

                XMLData +=

"</entry>";

               

byte[] byteArray = Encoding.UTF8.GetBytes(XMLData);

               

CredentialCache LoginCredentials = newCredentialCache();

               

string ContactURI = String.Format("https://api.constantcontact.com/ws/customers/{0}/{1}", API_USERNAME, API_RESOURCE_CAMPAIGNS);

                LoginCredentials.Add(

newUri(@"https://api.constantcontact.com/ws/customers/smimarketing"), "Basic", newNetworkCredential(API_KEY + @"%" + API_USERNAME, API_PASSWORD));

 

               

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ContactURI);

                request.Credentials = LoginCredentials;

                request.Method =

"POST";

                request.ContentType =

@"application/atom+xml";

                request.ContentLength = byteArray.Length;

               

Stream dataStream = request.GetRequestStream();

                dataStream.Write(byteArray, 0, byteArray.Length);

                dataStream.Close();

               

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

               

string returnString = response.StatusCode.ToString();

               

MessageBox.Show("done");

            }

           

catch(WebException ex)

            {

               

StreamReader reader = newStreamReader(ex.Response.GetResponseStream());

               

String responseBody = reader.ReadToEnd();

               

String responseCode = (((HttpWebResponse)ex.Response).StatusCode).ToString();

               

MessageBox.Show(responseBody);

                reader.Close();

            }

 

        }

Could you please provide the value of XMLData on this line after everything has been processed:

 

byte[] byteArray = Encoding.UTF8.GetBytes(XMLData);

Dave Berard
Senior Product Manager, Constant Contact
RachelE81
Frequent Participant

  XMLData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><entry xmlns=\"http://www.w3.org/2005/Atom\"><link href=\"/ws/customers/smimarketing/campaigns\" rel=\"edit\" /><id>http://api.constantcontact.com/ws/customers/smimarketing/campaigns</id><title type=\"text\">Test Email</title><updated>2011-10-30T19: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/smimarketing/campaigns/3\"><Name>API Test Email</Name><Status>Draft</Status><Date>2009-10-19T18:34:53.105Z</Date><Subject>Test Email</Subject><FromName>smi@strategicmarketing.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 aseparatewritten agreement with Constant Contact, neither the Constant Contact software, nor any content that appears on anyConstant Contact site,including but not limited to, web pages, newsletters, or templates may be reproduced, republished, repurposed, ordistributed without theprior written permission of Constant Contact.  For inquiries regarding reproduction or distribution of any ConstantContact material, pleasecontact 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>This is the text version.&lt;/Text></EmailTextContent><StyleSheet></StyleSheet><ContactLists><ContactList id=\"http://api.constantcontact.com/ws/customers/smimarketing/lists/1\"><link xmlns=\"http://www.w3.org/2005/Atom\" href=\"/ws/customers/smimarketing/lists/1\" rel=\"self\"/></ContactList></ContactLists><FromEmail><Email xmlns=\"http://ws.constantcontact.com/ns/1.0/\" id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/1\"><EmailAddress>r... xmlns=\"http://ws.constantcontact.com/ns/1.0/\" id=\"http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/2\"><EmailAddress>t... type=\"text\">Campaigns for customer: smimarketing</title><link href=\"campaigns\" /><link href=\"campaigns\" rel=\"self\" /><author><name>smimarketing</name></author><updated>2009-10-19T19:36:12.622Z</updated></source></entry>" string

There is at least one error in your XML builder.  Notice the line for creating the <OrganizationPostalCode> doesn't have the opening < character.  This would cause an XML validation error (which is why you're seeing the generic 400 error.

 

Additionally, though this could be caused by a copy/paste error, the <EmailAddress> nodes in what you pasted are completely incorrect.  Notice tha this is the content you pasted:

 

<FromEmail><Email xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/1"><EmailAddress>r... xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/smimarketing/settings/emailaddresses/2"><EmailAddress>t... type="text">Campaigns for customer: smimarketing</title>

 

If you look, the nodes are completely incorrect and there are elipses combined with unmatched nodes.  Given that your code looks like it is correctly creating the XML, I want to lean towards a copy/paste error here. 

 

 

Dave Berard
Senior Product Manager, Constant Contact
RachelE81
Frequent Participant

Thanks a billion Dave.  it was the < before the orgpost.  Also i used the copy and pasted of the RESTget.  Good call i had in my commented out portion the right XML if you see up further.  Anyway thanks again!

Developer Portal

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

Visit Page