Hi,
I am trying to update a campaign. Correct me if I am wrong but there are no methods to support this in the Java libraries.
This is how I am sending the xml below in Java:
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter(apiKey + "%" + user, password));
WebResource getCampaignResource = client.resource("https://api.constantcontact.com/ws/customers/me@mydomain.co.uk/campaigns/1106157784276");
String s = getCampaignResource.get(String.class);
//Alters the email content
String xml = parseGetCampaignResponse(s);
getCampaignResource.type("application/atom+xml").put(String.class, URLEncoder.encode(xml,"UTF-8"));
(variable xml is the xml below)
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<link href="/ws/customers/me@mydomain.co.uk/campaigns/1106157784276" rel="edit"></link>
<id>http://api.constantcontact.com/ws/customers/me@mydomain.co.uk/campaigns/1106157784276</id>
<title type="text">What's On Test</title>
<updated>2011-06-22T13:37:05.526Z</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/me@mydomain.co.uk/campaigns/1106157784276">
<Name>What's On Test</Name>
<Status>Draft</Status>
<Date>2011-06-22T13:37:05.526Z</Date>
<LastEditDate>2011-06-22T13:37:05.526Z</LastEditDate>
<Sent>0</Sent>
<Opens>0</Opens>
<Clicks>0</Clicks>
<Bounces>0</Bounces>
<Forwards>0</Forwards>
<OptOuts>0</OptOuts>
<SpamReports>0</SpamReports>
<SharePageURL></SharePageURL>
<Subject>What's On Test</Subject>
<FromName>Company Name</FromName>
<CampaignType>CUSTOM</CampaignType>
<ViewAsWebpage>YES</ViewAsWebpage>
<ViewAsWebpageLinkText>http://google.co.uk/</ViewAsWebpageLinkText>
<ViewAsWebpageText>Having trouble viewing this email?</ViewAsWebpageText>
<PermissionReminder>NO</PermissionReminder>
<GreetingSalutation>Dear</GreetingSalutation>
<GreetingName>FirstName</GreetingName>
<GreetingString>Greetings!</GreetingString>
<OrganizationName>Address Line 1</OrganizationName>
<OrganizationAddress1>Address Line 2</OrganizationAddress1>
<OrganizationAddress2>Address Line 3</OrganizationAddress2>
<OrganizationAddress3></OrganizationAddress3>
<OrganizationCity>City</OrganizationCity>
<OrganizationState></OrganizationState>
<OrganizationInternationalState></OrganizationInternationalState>
<OrganizationCountry>gb</OrganizationCountry>
<OrganizationPostalCode>LF11 7RF</OrganizationPostalCode>
<IncludeForwardEmail>YES</IncludeForwardEmail>
<ForwardEmailLinkText>Forward email</ForwardEmailLinkText>
<IncludeSubscribeLink>YES</IncludeSubscribeLink>
<SubscribeLinkText>Subscribe me!</SubscribeLinkText>
<EmailContentFormat>HTML</EmailContentFormat>
<EmailContent><html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:cctd="http://www.constantcontact.com/cctd">
<body><CopyRight>Copyright (c) 1996-2011 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.</CopyRight>
<OpenTracking/>
<CustomBlock name="letter.intro" title="Personalization">
<Greeting/>
</CustomBlock>
<table width="100%" border="0" cellspacing="20" cellpadding="20">
<tr>
<td>Hello World</td>
<td>Hello World Description</td>
</tr>
</table>
</body>
</html></EmailContent>
<EmailTextContent><Text><Greeting/></Text></EmailTextContent>
<StyleSheet></StyleSheet>
<ArchiveStatus></ArchiveStatus>
<ArchiveURL></ArchiveURL>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/me@mydomain.co.uk/lists/16">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/me@mydomain.co.uk/lists/16" rel="self"></link>
</ContactList>
</ContactLists>
<FromEmail>
<Email id="http://api.constantcontact.com/ws/customers/me@mydomain.co.uk/settings/emailaddresses/1">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/me@mydomain.co.uk/settings/emailaddresses/1" rel="self"></link>
</Email>
<EmailAddress>me@mydomain.co.uk</EmailAddress>
</FromEmail>
<ReplyToEmail>
<Email id="http://api.constantcontact.com/ws/customers/me@mydomain.co.uk/settings/emailaddresses/1">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/me@mydomain.co.uk/settings/emailaddresses/1" rel="self"></link>
</Email>
<EmailAddress>me@mydomain.co.uk</EmailAddress>
</ReplyToEmail>
</Campaign>
</content>
<source>
<id>http://api.constantcontact.com/ws/customers/me@mydomain.co.uk/campaigns</id>
<title type="text">Campaigns for customer: me@mydomain.co.uk</title>
<link href="campaigns"></link>
<link href="campaigns" rel="self"></link>
<author>
<name>me@mydomain.co.uk</name>
</author>
<updated>2011-06-23T11:29:10.421Z</updated>
</source>
</entry>
The error I am getting is:
Error 400: The request contains errors in the common Atom sections, which lie outside <entry> or <Content>, such as <feed>, <id>, <author> or <updated>.
Any help would be appreciated.
Thanks
Hello,
I took a look at your XML and tried to recreate the error you were having. 400 errors usually mean that there is an XML error. However, I was able to take your XML and post it as a new email, and then take the same XML and change the name of the email and update it.
While I am not a Java developer, if you could send me the full code that you are using, I can try to run it on my end, and see if I can find out why you are getting this error.
Regards,
Hai i have the same issue here is my xml
<entry xmlns="http://www.w3.org/2005/Atom">
<link href="/ws/customers/lijoejohn/campaigns" rel="edit" />
<id>http://api.constantcontact.com/ws/customers/lijoejohn/campaigns</id>
<title type="text">12-04-17 : Tackle your Beauty Regimen with Basicare! Get a Beauty Essentials Hamper for ONLY Rs.3</title>
<updated>2009-10-19T18: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/lijoejohn/campaigns/1100546096289">
<Name>12-04-17 : Tackle your Beauty Regimen with Basicare! Get a Beauty Essentials Hamper for ONLY Rs.3</Name>
<Status>Draft</Status>
<Date>2009-10-19T18:34:53.105Z</Date>
<Subject>Tackle your Beauty Regimen with Basicare! Get a Beauty Essentials Hamper for ONLY Rs.399! Include</Subject>
<FromName>Deal Test</FromName>
<ViewAsWebpage>YES</ViewAsWebpage>
<ViewAsWebpageLinkText>Click here</ViewAsWebpageLinkText>
<ViewAsWebpageText>Having trouble viewing this email?</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><html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:cctd="http://www.constantcontact.com/cctd">
<body><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 tblasen@example.com.</CopyRight>
<OpenTracking/>
<!-- Do NOT delete previous line if you want to get statistics on the number of opened emails -->
<CustomBlock name="letter.intro" title="Personalization">
<Greeting/>
</CustomBlock>
</body>
</html></EmailContent>
<EmailTextContent><Text>This is the text version.</Text></EmailTextContent>
<StyleSheet></StyleSheet>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/lijoejohn/lists/56">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/lijoejohn/lists/56" rel="self" />
</ContactList>
</ContactLists>
<FromEmail>
<Email id="http://api.constantcontact.com/ws/customers/lijoejohn/settings/emailaddresses/1">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/lijoejohn/settings/emailaddresses/1"
rel="self" />
</email>
<EmailAddress>lijo_e@ispg.in</EmailAddress>
</FromEmail>
<ReplyToEmail>
<Email id="http://api.constantcontact.com/ws/customers/lijoejohn/settings/emailaddresses/1">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/lijoejohn/settings/emailaddresses/1"
rel="self" />
</Email>
<EmailAddress>lijo_e@ispg.in</EmailAddress>
</ReplyToEmail>
</Campaign>
</content>
<source>
<id>http://api.constantcontact.com/ws/customers/lijoejohn/campaigns</id>
<title type="text">Campaigns for customer: lijoejohn</title>
<link href="campaigns" />
<link href="campaigns" rel="self" />
<author>
<name>lijoejohn</name>
</author>
<updated>2009-10-19T18:34:53.105Z</updated>
</entry>
after curling getting the response as
"
Error 400: The request contains errors in the common Atom sections, which lie outside <entry> or <Content>, such as <feed>, <id>, <author> or <updated>.
"
Hey Lijo,
I noticed a few problems with that XML, and when I made these changes, I was able to POST the same XML to my account to create a campaign. You should include an XML tag, the <campaign> tag on line 10 should be capitalized, and there is no closing tag for your Source.
<?xml version='1.0' encoding='UTF-8'?> <entry xmlns="http://www.w3.org/2005/Atom"> <link href="/ws/customers/lijoejohn/campaigns" rel="edit" /> <id>http://api.constantcontact.com/ws/customers/lijoejohn/campaigns</id> <title type="text">12-04-17 : Tackle your Beauty Regimen with Basicare! Get a Beauty Essentials Hamper for ONLY Rs.3</title> <updated>2009-10-19T18: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/lijoejohn/campaigns/1100546096289"> <Name>12-04-17 : Tackle your Beauty Regimen with Basicare! Get a Beauty Essentials Hamper for ONLY Rs.3</Name> <Status>Draft</Status> <Date>2009-10-19T18:34:53.105Z</Date> <Subject>Tackle your Beauty Regimen with Basicare! Get a Beauty Essentials Hamper for ONLY Rs.399! Include</Subject> <FromName>Deal Test</FromName> <ViewAsWebpage>YES</ViewAsWebpage> <ViewAsWebpageLinkText>Click here</ViewAsWebpageLinkText> <ViewAsWebpageText>Having trouble viewing this email?</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><html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:cctd="http://www.constantcontact.com/cctd"> <body><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 tblasen@example.com.</CopyRight> <OpenTracking/> <!-- Do NOT delete previous line if you want to get statistics on the number of opened emails --> <CustomBlock name="letter.intro" title="Personalization"> <Greeting/> </CustomBlock> </body> </html></EmailContent> <EmailTextContent><Text>This is the text version.</Text></EmailTextContent> <StyleSheet></StyleSheet> <ContactLists> <ContactList id="http://api.constantcontact.com/ws/customers/lijoejohn/lists/56"> <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/lijoejohn/lists/56" rel="self" /> </ContactList> </ContactLists> <FromEmail> <Email id="http://api.constantcontact.com/ws/customers/lijoejohn/settings/emailaddresses/1"> <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/lijoejohn/settings/emailaddresses/1" rel="self" /> </email> <EmailAddress>lijo_e@ispg.in</EmailAddress> </FromEmail> <ReplyToEmail> <Email id="http://api.constantcontact.com/ws/customers/lijoejohn/settings/emailaddresses/1"> <link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/lijoejohn/settings/emailaddresses/1" rel="self" /> </Email> <EmailAddress>lijo_e@ispg.in</EmailAddress> </ReplyToEmail> </Campaign> </content> <source> <id>http://api.constantcontact.com/ws/customers/lijoejohn/campaigns</id> <title type="text">Campaigns for customer: lijoejohn</title> <link href="campaigns" /> <link href="campaigns" rel="self" /> <author> <name>lijoejohn</name> </author> <updated>2009-10-19T18:34:53.105Z</updated> </source> </entry>
Nick G thanks for your replay
While am trying to post the xml which you corrected using the JAVA REST CLIENT TOOL am getting the same error
"Error 400: The request contains errors in the common Atom sections, which lie outside <entry> or <Content>, such as <feed>, <id>, <author> or <updated>."
POST URL :-https://api.constantcontact.com/ws/customers/lijoejohn/campaigns
USer NAme :-REMOVED FOR SECURITY PURPOSES
password :-REMOVED FOR SECURITY PURPOSES
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
<link href="/ws/customers/lijoejohn/campaigns" rel="edit" />
<id>http://api.constantcontact.com/ws/customers/lijoejohn/campaigns</id>
<title type="text">12-04-17 : Tackle your Beauty Regimen with Basicare! Get a Beauty Essentials Hamper for ONLY Rs.3</title>
<updated>2009-10-19T18: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/lijoejohn/campaigns/1100546096289">
<Name>12-04-17 : Tackle your Beauty Regimen with Basicare! Get a Beauty Essentials Hamper for ONLY Rs.3</Name>
<Status>Draft</Status>
<Date>2009-10-19T18:34:53.105Z</Date>
<Subject>Tackle your Beauty Regimen with Basicare! Get a Beauty Essentials Hamper for ONLY Rs.399! Include</Subject>
<FromName>Deal Test</FromName>
<ViewAsWebpage>YES</ViewAsWebpage>
<ViewAsWebpageLinkText>Click here</ViewAsWebpageLinkText>
<ViewAsWebpageText>Having trouble viewing this email?</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><html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:cctd="http://www.constantcontact.com/cctd">
<body><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 tblasen@example.com.</CopyRight>
<OpenTracking/>
<!-- Do NOT delete previous line if you want to get statistics on the number of opened emails -->
<CustomBlock name="letter.intro" title="Personalization">
<Greeting/>
</CustomBlock>
</body>
</html></EmailContent>
<EmailTextContent><Text>This is the text version.</Text></EmailTextContent>
<StyleSheet></StyleSheet>
<ContactLists>
<ContactList id="http://api.constantcontact.com/ws/customers/lijoejohn/lists/56">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/lijoejohn/lists/56" rel="self" />
</ContactList>
</ContactLists>
<FromEmail>
<Email id="http://api.constantcontact.com/ws/customers/lijoejohn/settings/emailaddresses/1">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/lijoejohn/settings/emailaddresses/1"
rel="self" />
</email>
<EmailAddress>lijo_e@ispg.in</EmailAddress>
</FromEmail>
<ReplyToEmail>
<Email id="http://api.constantcontact.com/ws/customers/lijoejohn/settings/emailaddresses/1">
<link xmlns="http://www.w3.org/2005/Atom" href="/ws/customers/lijoejohn/settings/emailaddresses/1"
rel="self" />
</Email>
<EmailAddress>lijo_e@ispg.in</EmailAddress>
</ReplyToEmail>
</Campaign>
</content>
<source>
<id>http://api.constantcontact.com/ws/customers/lijoejohn/campaigns</id>
<title type="text">Campaigns for customer: lijoejohn</title>
<link href="campaigns" />
<link href="campaigns" rel="self" />
<author>
<name>lijoejohn</name>
</author>
<updated>2009-10-19T18:34:53.105Z</updated>
</source>
</entry>
can u please check it. ??
Hello,
You have a couple of issues with this. One is that your campaign name, see elements on line 5 and line 12, is too long. There is an 80 character limit for email names. The other issue is that on line 68, the close tag for the email element should include a capital E to start (e.g., </Email>).
Shortening your title and fixing that close tag should get you going.
Cheers,
Ok thanks Mark
I have a doubt is the capitalization for the XML tag is must ? i mean is there any processing error between
<Email></Email> and <email></email> ?
The specific reason your code was throwing an error is because your first tag was capitalized, and your second one didn't match, since it was lower case. You probably won't receive an error doing both of the tags as lower-case, but I would suggest keeping them capitalized.
Just to follow on what Nick explained, XML sytax rules allow for variation in case in element names <ElementName>, but they also require that the case matches in the open and close tags of each element <ElementName></ElementName>. In addition, our API's adhere to camel notation, so the first letter of each word concatenated to form element names need to be capitalized for your XML to work.
I have updated your post to remove your username and password from the body of the post. As these are public forums, anyone could look at your post and have gotten access to your account. It is highly recommend that you change your password and/or username to prevent people who may have seen the post prior to my edits from still having access.
The holidays have come and gone. For many seasonal businesses, this means the rush of shoppers has decreased as well. Instead of turning off the lights and waiting for spring, make your email marketi...
See Article