danesparza / MailChimp.NET

:envelope: .NET Wrapper for the MailChimp v2.0 API
MIT License
179 stars 119 forks source link

incremental (initial) loading #169

Closed utillity closed 8 years ago

utillity commented 8 years ago

I want to load a large list in batches of lets say 100 records. for that I need to use GetAllMembersForList and set the sort_field parameter to "last_changed" (I guess) and use a segment (filter) to only get the records which have a last_changed later than the highest date/time of the last batch. but no matter which value I set for sort_field, I always get the same rows in the same order. I Tried "last_changed", "timestamp", "info_changed".

My segment is as follows:

            var result = new CampaignSegmentOptions
            {
                Match = "all",
                Conditions = new List<CampaignSegmentCriteria>()
            };
            var crit = new CampaignSegmentCriteria
            {
                Field = "last_changed",
                Operator = "gt",
                Value = MailChimpManager.ConvertDateTimeToMailChimpAPI(lastSync.Value)
            };
            result.Conditions.Add(crit);
utillity commented 8 years ago

ok, never mind. checked the API and your source-code. It seems, you must pass "last_update_time" as the sort-field (https://apidocs.mailchimp.com/api/2.0/lists/members.php) and this seems to work