I have an email with the status "Do Not Mail". I am using the following to build my post info:
postInfo = "<entry xmlns=""http://www.w3.org/2005/Atom"">" &vbCrLF
postInfo = postInfo & "<title type=""text""></title>" &vbCrLF
postInfo = postInfo & "<updated>" & date &"</updated>" &vbCrLF
postInfo = postInfo & "<author></author>" &vbCrLF
postInfo = postInfo & "<id>data:,none</id>" &vbCrLF
postInfo = postInfo & "<summary type=""text"">Contact</summary>" &vbCrLF
postInfo = postInfo & "<content type=""application/vnd.ctct+xml"">" &vbCrLF
postInfo = postInfo & "<Contact xmlns=""http://ws.constantcontact.com/ns/1.0/"">" &vbCrLF
postInfo = postInfo & "<OptInSource>ACTION_BY_CONTACT</OptInSource>" &vbCrLF
postInfo = postInfo & "<ContactLists>" &vbCrLF
postInfo = postInfo & "<ContactList id=""http://api.constantcontact.com/ws/customers/UN/lists/1""></ContactList>" &vbCrLF
postInfo = postInfo & "</ContactLists>" &vbCrLF
postInfo = postInfo & "</Contact>" &vbCrLF
postInfo = postInfo & "</content>" &vbCrLF
postInfo = postInfo & "</entry>" &vbCrLF
My connstring is using this format:
http://api.constantcontact.com/ws/customers/UN/contacts/9999
its actually using https versus http and 9999 would be the actual contact_id
and Method is PUT
When I run it, I get the following error:
Error 409: The request contains errors in the common Atom sections, which lie outside or , such as , , or . |
Am I missing something in building my post that is causing this error?
Solved! Go to Solution.
Hey,
What you want to do is reformat the XML so it includes the ID like so:
postInfo = "<entry xmlns=""http://www.w3.org/2005/Atom"">" &vbCrLF postInfo = postInfo & "<title type=""text""> </title>" &vbCrLF postInfo = postInfo & "<updated>2008-07-23T14:21:06.407Z</updated>" &vbCrLF postInfo = postInfo & "<author></author>" &vbCrLF postInfo = postInfo & "<id>http://api.constantcontact.com/ws/customers/USERNAME/contacts/CONTACTID</id>" &vbCrLF postInfo = postInfo & "<summary type=""text"">Contact</summary>" &vbCrLF postInfo = postInfo & "<content type=""application/vnd.ctct+xml"">" &vbCrLF postInfo = postInfo & "<Contact xmlns=""http://ws.constantcontact.com/ns/1.0/"">" &vbCrLF postInfo = postInfo & "<EmailAddress>test_100@example.com</EmailAddress>" &vbCrLF postInfo = postInfo & "<OptInSource>ACTION_BY_CONTACT</OptInSource>" &vbCrLF postInfo = postInfo & "<ContactLists>" &vbCrLF postInfo = postInfo & "<ContactList id=""http://api.constantcontact.com/ws/customers/UN/lists/1"" />" &vbCrLF postInfo = postInfo & "</ContactLists>" &vbCrLF postInfo = postInfo & "</Contact>" &vbCrLF postInfo = postInfo & "</content>" &vbCrLF postInfo = postInfo & "</entry>" &vbCrLF
The email address that you are putting must match the ID that it is assigned in our system. Otherwise you will get an error such as yours.
Let me know if this helps.
Hi Everett,
I believe that you are forgetting to provide an email address when you are doing your PUT.
<entry xmlns="http://www.w3.org/2005/Atom"> <title type="text"> </title> <updated>2008-07-23T14:21:06.407Z</updated> <author></author> <id>data:,none</id> <summary type="text">Contact</summary> <content type="application/vnd.ctct+xml"> <Contact xmlns="http://ws.constantcontact.com/ns/1.0/"> <EmailAddress>test_100@example.com</EmailAddress> <OptInSource>ACTION_BY_CONTACT</OptInSource> <ContactLists> <ContactList id="http://api.constantcontact.com/ws/customers/joesflowers/lists/1" /> </ContactLists> </Contact> </content> </entry>
Please let me know if this helps,
I tried both options with the same results.
I am still having problems with this and I've added the EmailAddress tag and it still does not allow me to Opt-In and it gives me this error:
Error 409: The request contains errors in the common Atom sections, which lie outside or , such as , , or .
Hey Everett,
Can you please try the following code for me to see what happens;
postInfo = "<entry xmlns=""http://www.w3.org/2005/Atom"">" &vbCrLF postInfo = postInfo & "<title type=""text""> </title>" &vbCrLF postInfo = postInfo & "<updated>2008-07-23T14:21:06.407Z</updated>" &vbCrLF postInfo = postInfo & "<author></author>" &vbCrLF postInfo = postInfo & "<id>data:,none</id>" &vbCrLF postInfo = postInfo & "<summary type=""text"">Contact</summary>" &vbCrLF postInfo = postInfo & "<content type=""application/vnd.ctct+xml"">" &vbCrLF postInfo = postInfo & "<Contact xmlns=""http://ws.constantcontact.com/ns/1.0/"">" &vbCrLF postInfo = postInfo & "<EmailAddress>test_100@example.com</EmailAddress>" &vbCrLF postInfo = postInfo & "<OptInSource>ACTION_BY_CONTACT</OptInSource>" &vbCrLF postInfo = postInfo & "<ContactLists>" &vbCrLF postInfo = postInfo & "<ContactList id=""http://api.constantcontact.com/ws/customers/UN/lists/1"" />" &vbCrLF postInfo = postInfo & "</ContactLists>" &vbCrLF postInfo = postInfo & "</Contact>" &vbCrLF postInfo = postInfo & "</content>" &vbCrLF postInfo = postInfo & "</entry>" &vbCrLF
I am not familiar with the language but I know that XML to be correct.
Please keep me updated on how this works.
Okay, so here's what I did using test_100@example.com.
I used the POST method to add the email to list 2. That worked successfully. The OptInSource value is "ACTION_BY_CONTACT"
I then used the DELETE method to unsubscribe the same email account which put the status of the email to "Do Not Email" which it was suppose to do.
I then try to use the PUT method to perform the Contact Opt-In step which I used your code changing the UN value to the customer's username. I get the following error:
Error 409: The request contains errors in the common Atom sections, which lie outside or , such as , , or
Hi Everett,
When doing a PUT you have to define which ID you are putting instead of the "data:,none" which is there now. You need to use the contacts ID which you can get by using the rest client. I would suggest downloading the the rest client from here.
Once you download the rest client I would do the same process again with a different email address and do a GET with the rest client to see how the XML changes through out the process.
Let me know if this helps.
Unfortunately, I am unable to download the RestClient jar file. My virus protection software blocks me from running the file. I did change the field as you suggested to use the actual contact id of the email address that I am trying to perform the Opt-In functionality.
It looks like this: postInfo = postInfo & "<id>data:,1904</id>" &vbCrLF
The resource that I am performing the PUT with looks like this:
https://api.constantcontact.com/ws/customers/username/contacts/1904
I know I am missing something simple. All of the other calls work great, I even use the GET method to get the contact_id of the email address I want to Opt-In.
Okay, I was able to download the RestClient and I entered the url address which contains the contactID of the email to OptIn, enter the login and password and I got the following message in the Body tab window:
Error 400: The request contains errors in the common Atom sections, which lie outside <entry> or <Content>, such as <feed>, <id>, <author> or <updated>.
This is weird.....
Hey,
What you want to do is reformat the XML so it includes the ID like so:
postInfo = "<entry xmlns=""http://www.w3.org/2005/Atom"">" &vbCrLF postInfo = postInfo & "<title type=""text""> </title>" &vbCrLF postInfo = postInfo & "<updated>2008-07-23T14:21:06.407Z</updated>" &vbCrLF postInfo = postInfo & "<author></author>" &vbCrLF postInfo = postInfo & "<id>http://api.constantcontact.com/ws/customers/USERNAME/contacts/CONTACTID</id>" &vbCrLF postInfo = postInfo & "<summary type=""text"">Contact</summary>" &vbCrLF postInfo = postInfo & "<content type=""application/vnd.ctct+xml"">" &vbCrLF postInfo = postInfo & "<Contact xmlns=""http://ws.constantcontact.com/ns/1.0/"">" &vbCrLF postInfo = postInfo & "<EmailAddress>test_100@example.com</EmailAddress>" &vbCrLF postInfo = postInfo & "<OptInSource>ACTION_BY_CONTACT</OptInSource>" &vbCrLF postInfo = postInfo & "<ContactLists>" &vbCrLF postInfo = postInfo & "<ContactList id=""http://api.constantcontact.com/ws/customers/UN/lists/1"" />" &vbCrLF postInfo = postInfo & "</ContactLists>" &vbCrLF postInfo = postInfo & "</Contact>" &vbCrLF postInfo = postInfo & "</content>" &vbCrLF postInfo = postInfo & "</entry>" &vbCrLF
The email address that you are putting must match the ID that it is assigned in our system. Otherwise you will get an error such as yours.
Let me know if this helps.
Okay, I did that also and got the same error.
Hold it, what, I just do not believe it, BUT, that worked. I used https versus http. It worked, it really, really worked. So, why doesn't the documentation provide this info?
Thanks so much for helping me with this or I would have never figured it out.
Hi Everett,
It is mentioned in our API documentation under our Authentication which you can find here. The id isn't being requested over HTTP is the correct URI for the ID.
I am glad to help you out Everette, let me know if you need any more assistance.
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