We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Update Contact to add to a list Java

techiewaves
Regular Participant

Update Contact to add to a list Java

I am trying to Update the contact to add to a list. Tried doing a PUT with following two XML blocks. But we always get 401. We are using Basic Authentication type with AbderaClient.


Sample 1.


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

  <id>http://api.constantcontact.com/ws/customers/happier.trial/contacts/6</id>

  <title type="text"></title>

  <author>

    <name>happier.trial</name>

  </author>

  <summary type="text">Contact</summary>

  <updated>2009-10-14T18:10:09.968Z</updated>

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

    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/happier.trial/contacts/6">

      <EmailAddress>aaa@aaa.com</EmailAddress>

      <OptInSource>ACTION_BY_CUSTOMER</OptInSource>

      <ContactLists>

        <ContactList id="http://api.constantcontact.com/ws/customers/happier.trial/lists/17"></ContactList>

      </ContactLists>

    </Contact>

  </content>

</entry>



Sample2.

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

  <id>http://api.constantcontact.com/ws/customers/happier.trial/contacts/6</id>

  <title type="text"></title>

  <author>

    <name>happier.trial</name>

  </author>

  <summary type="text">Contact</summary>

  <updated>2009-10-14T20:11:47.500Z</updated>

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

    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/happier.trial/contacts/6">

      <EmailAddress>aaa@aaaacom</EmailAddress>

      <OptInSource>ACTION_BY_CUSTOMER</OptInSource>

      <ContactLists>

        <ContactList id="http://api.constantcontact.com/ws/customers/happier.trial/lists/17">

          <OptInSource>ACTION_BY_CUSTOMER</OptInSource>

        </ContactList>

      </ContactLists>

    </Contact>

  </content>

</entry>


 


What am I missing?


Lokesh


 

3 REPLIES 3
jamesbensonuk
Regular Participant

Hi,


I can see you have a slight error in your XML code, I think that might be your issue.


<ContactLists>

<ContactList id="http://api.constantcontact.com/ws/customers/happier.trial/lists/17">

<OptInSource>ACTION_BY_CUSTOMER</OptInSource>

</ContactList>

</ContactLists>


 


You should not have the line <OptInSource>ACTION_BY_CUSTOMER</OptInSource> in that position.


 


 

James Benson, PHP Developer.


Constant Contact Services: http://integrationservic.es/

techiewaves
Regular Participant

In Sample 1 I tried it without the <OptInSource>ACTION_BY_CUSTOMER</OptInSource> inside the ContactList.


Didn't work then I Tried putting it in the ContactList and didn't work either.


Thanks

techiewaves
Regular Participant

With PUT using Sample1


I had to replace http with https in the URL for contact that I was getting from the GET request for Contact by email (/contacts?email=)


I did a PUT to  https://api.constantcontact.com/ws/customers/{USER}/contacts/6


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

  <id>http://api.constantcontact.com/ws/customers/{USER}/contacts/6</id>

  <title type="text"></title>

  <author>

    <name>happier.trial</name>

  </author>

  <summary type="text">Contact</summary>

  <updated>2009-10-14T18:10:09.968Z</updated>

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

    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/" id="http://api.constantcontact.com/ws/customers/{USER}/contacts/6">

      <EmailAddress>aaa@aaa.com</EmailAddress>

      <OptInSource>ACTION_BY_CUSTOMER</OptInSource>

      <ContactLists>

        <ContactList id="http://api.constantcontact.com/ws/customers/{USER}/lists/17"></ContactList>

      </ContactLists>

    </Contact>

  </content>

</entry>


 

Developer Portal

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

Visit Page