Need help with managing already registered users through the API


Need help with managing already registered users through the API

Hi there,


So I successfully integrated the API into my website, however I am having some issues with trying to update a user that is already on a current list but wants to join other lists.


My environment is Ruby on Rails, i use the constant contact gem which I forked here to fix some issues


I tried to use that specific gem to do the updating as per their documentation however it is a very old gem and was hard enough to get working on just creating a new user.


So basically what I am doing is going to try and create a new user via the gem, then if I get an error back I will make a manual request to get the XML data for that individual and try to update the lists that they belong to.


This gave me problems though. I tried following these guidelines:


However on the first one I ran into a problem. I was successfully able to get the data for a specific user by accessing, but it will not show me the lists that the user is apart of. Has there been a change in the API that adjusts how lists are retrieved and updated for a specific user? This may be why the gem is breaking for me.


Hi Jordan,


I will check out that gem and see if I have any luck doing a PUT to update a current contact and get back to you.  As far as the issues you were receiving with getting contact details by emailaddress and missing Lists, this was how the API was designed.  In order to get a list of lists a contact is in, you have to do a get on the collection by ID not by searching for an email address.  


If you would like a Ruby example, I can provide you with specifics, just let me know.  


Andrew Weber
Associate Product Manager for EventSpot

I think I figured it out now, thanks for the quick response!

Hey andrew it would be helpful if you can provide a ruby sample for fetching contacts by list_id.



In order to get all contacts that are members of a list with our Ruby SDK, you can use the following code snippet:


    cc ='API_KEY')
    @contacts = []
    request_params = nil

    # By Uncommenting the two lines below, you can add additional parameters
    #params = { modified_since: "2014-12-02T01:43:19Z", limit: 500 }
    #request_params = '?' + ConstantContact::Util::Helpers.http_build_query(params)
    result = cc.get_contacts_from_list('ACCESS_TOKEN", LIST_ID, request_params)
    result.results.each { |r| @contacts << r }
    while do
        result = cc.get_contacts_from_list('ACCESS_TOKEN',LIST_ID,
        result.results.each { |r| @contacts << r }

The result will be all contacts that are members of the list loaded to the @contacts global array.


If you have any questions about this snippet, please let me know!


Edit: Remove 2 lines of code that accomplished nothing.



Elijah G.
API Support Engineer
Developer Portal

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

Visit Page