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.

Get Contacts By List Type LastUpdateTime is Null

JeffryP
Member

Get Contacts By List Type LastUpdateTime is Null

I'm getting the entire list of Removed & DoNotMail contacts each time; at first I thought I had a malformed cutoff date, but that wasn't the case; I tried some string.format functions but they didn't throw an error but no contacts were returned, I used "3/2/2012 15:34:234" which doesn't look very Atom like but I returned contacts.

 

When I debug and inspect the feed I can see every record that I checked as having null values for LastUpdateTime as well as the OptOut time, source & reason.

 

I was somehow hoping that the LastUpdateTime would be updated by the CtCt system.

 

Is the only way to populate the lastupdatetime is to re-put each one? Yikes, there are over 17k of Active contacts and those would be nice to have sync'd as well.

 

I'm wondering if the reason no contacts were returned with the "2012-03-01T14:21:06.2079087Z" was because the field is null, but and when I used the date formatted "3/2/2012 15:34:234" it was ignored and all the contacts were returned?

 

Anyway, the real issue appears to be the unpopulated LastUpdateTime

5 REPLIES 5
Nick_G
Moderator

Hey Jeffry,

 

The LastUpdateTime value shouldn't be null. I tested this to be sure, but when you GET a contact that has been inserted, and no other changes have been made, the LastUpdateTime is the same as the InserTime in Atom format.

 

I'd like to see how you're getting these results. Would you be able to provide the code you're using? If you can send us what your code looks like to webservices@constantcontact.com, as well as any XML you're passing, we can help look into the results.

Nick Galbraith
Support Engineer

Other than my own GetResponseStream method all the other methods are CtCt code.

 

stream = GetResponseStream(address, uriCredNet, netCredAuth, pwd);

where the vars are...

address=https://api.constantcontact.com/ws/customers/myUserIDdev/contacts?updatedsince=3/5/2012 7:44:38 pm&listtype=active

 

netCredentials = https://api.constantcontact.com/ws/customers?myUserIDdev

auth = myapikey + myUserIDdev

pwd = myPwd

 

Then the stream is run through the method "ContactComponent.GetContactCollection"

List<Contact> contacts = (List<Contact>)ContactComponent.GetContactCollection(stream, out nxtChunkId);

 

I get five contacts back in Active and if I pause during debug and I see the _LastUpdateTime & LastUpdateTime are null for all 5. I've done the same for my/our client with about 500 contacts in the Removed and about 500 in DoNotMail and those too were all null.

 

Should I do something with the response stream before I pass it into the method to make the contact collection?

 

Thanks in Advance...

It sounds like there is a bug in the C# wrapper in parsing the XML.  Will take a look at the current version of the wrapper and make sure that it is working correctly. 

Dave Berard
Senior Product Manager, Constant Contact

Your reply confirmed that this was expected behavior, I debugged on the ContactComponent GetContactCollection and it adds to the contact list each conact using GetContact, which is very basic info, rather than ContactDetails, which is understandable in that I may not want the ContactLists and all the custom fields, or maybe I would?.

 

I also replaced all the wrapper cs files with the dll's and the same result, so it would appear that your wrapper is working just like the dll :(

 

I may just abandon the method and instead us my StreamToDataSet method, and just append a .Net dataset, I'm doing an insert to Sql w/a dataset, so I'll skip the step of creating the List<contact>

 

A dataset is nice because it accomodates many tables if the XML contains many w/out having to do any tricks.

ds.Tables["Contact"].Rows[i]["LastUpdateTime"] Looping through is just as easy (maybe easier) than looping through XML, I'm not sure if it's a bigger burden on the server to manage the datasets over XML (I rather think it is).

 

     private static DataSet StreamToDataSet(Stream stream)
        {
            DataSet ds = new DataSet();
            StreamReader sR = StreamReader.Null;
            if (stream != null)
            {
                sR = new StreamReader(stream);
                try
                {
                    ds.ReadXml(sR);             
                }
                catch (Exception Ex)
                {
                    MessageBox.Show("Error - StreamToDataSet: " + Ex.Message);
                }
            }            
            return ds;
        }

 I just need to manage re-getting the stream into a tmpDs, extract the Contact tmpDt (datatable) and append that data into a master datatable ctct[ListType] then call my existing method to insert to Sql.

 

Here's the skimpy method from the contact component... Perhaps I could just add the missing items, but I'd have to remember that when & if I choose to use the Dlls.  I'm not sure you'll want to update the Dll to fix this, if anyone wants a C# work-around using DataTables send me a PM, and/or get the cs files and copy the private method to getdetails, or stick with the cs files and mod them.

 

       private static Contact GetContact(XPathNavigator node, IXmlNamespaceResolver resolver)
        {
            Contact c = new Contact();
            c.Link = GetContactLink(node, resolver);

            const string xpathSelect = @"at:content/cc:Contact";

            XPathNodeIterator contactNodes = node.Select(xpathSelect, resolver);

            while (contactNodes.MoveNext())
            {
                XPathNavigator currentContactNode = contactNodes.Current;

                c.Id = GetContactId(currentContactNode);

                if (currentContactNode.HasChildren)
                {
                    currentContactNode.MoveToFirstChild();
                    do
                    {
                        switch (currentContactNode.Name)
                        {
                            case ContactXmlElementName:
                                c.Name = currentContactNode.Value;
                                break;
                            case ContactXmlElementEmailAddresss:
                                c.EmailAddress = currentContactNode.Value;
                                break;
                            case ContactXmlElementEmailType:
                                c.EmailType = GetEmailType(currentContactNode.Value);
                                break;
                            case ContactXmlElementOptInSource:
                                c.OptInSource = GetOptSource(currentContactNode.Value);
                                break;
                            case ContactXmlElementOptInTime:
                                c.OptInTime = currentContactNode.ValueAsDateTime;
                                break;
                            case ContactXmlElementStatus:
                                c.Status = GetContactStatus(currentContactNode.Value);
                                break;
                            case ContactXmlElementConfirmed:
                                c.Confirmed = currentContactNode.ValueAsBoolean;
                                break;
                            case ContactXmlElementInsertTime:
                                c.InsertTime = currentContactNode.ValueAsDateTime;
                                break;
                            default:
                                //System.Diagnostics.Debugger.Break();
                                break;
                        }

                    } while (currentContactNode.MoveToNext());
                }

                break;
            }

            return c;
        }

Looking into what you reported definitely looks like there is a bg in the C# wrapper.  I was unaware that there were two XML parsing methods for Contact resources, there should only be one.  Will update the C# wrapper and correct the issue, should have an updated library in the repository early today with recompiled DLL files.

Dave Berard
Senior Product Manager, Constant Contact
Developer Portal

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

Visit Page