danesparza / MailChimp.NET

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

Getting the Grouping ID #162

Open dorofino opened 9 years ago

dorofino commented 9 years ago

Hi ,

On your documentation you mentioned to add your Group ID. This ID is coming from where, MailChimp? if so the GroupID is a string and not a Int.

can some one help me with this, thanks

myMergeVars.Groupings[0].Id = 1234; // replace with your grouping id

AmadeusW commented 8 years ago

@dorofino here's the code I used to get all grouping information:

            MailChimpManager mc = new MailChimpManager(APIKEY);

            var lists = mc.GetLists().Data;
            foreach (var list in lists)
            {
                var listName = list.Name;
                var listId = list.Id;
                try
                {
                    // When a group has no interest groupings, an exception is thrown
                    var groupings = mc.GetListInterestGroupings(listId);

                    foreach (var grouping in groupings)
                    {
                        var groupingId = grouping.Id;
                        var innerGroups = grouping.GroupNames;
                        foreach (var innerGroup in innerGroups)
                        {
                            var gname = innerGroup.Name;
                            var gbit = innerGroup.Bit;
                        }
                    }
                }
                catch
                { }
            }