cancel
Showing results for 
Search instead for 
Did you mean: 
Due to an issue with YouTube, inserting videos in your emails is showing an error. Until they are able to resolve this issue, we recommend using a different video hosting service. We will continue to monitor this outage and update you as we have more information.

OptIn Error

SOLVED
Occasional Advisor

OptIn Error

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?

12 REPLIES 12
CTCT Employee

Re: OptIn Error

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,

Ryan Davis
Quality Engineer
Occasional Advisor

Re: OptIn Error

I tried both options with the same results. 

Occasional Advisor

Re: OptIn Error

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 .

 

CTCT Employee

Re: OptIn Error

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.

Ryan Davis
Quality Engineer
Highlighted
Occasional Advisor

Re: OptIn Error

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

 

CTCT Employee

Re: OptIn Error

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.

Ryan Davis
Quality Engineer
Occasional Advisor

Re: OptIn Error

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.

Occasional Advisor

Re: OptIn Error

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.....

CTCT Employee

Re: OptIn Error

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.

Ryan Davis
Quality Engineer