Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Array is not a valid interest group #202

Open
alexbitsnz opened this issue Oct 31, 2016 · 1 comment
Open

Array is not a valid interest group #202

alexbitsnz opened this issue Oct 31, 2016 · 1 comment
Labels

Comments

@alexbitsnz
Copy link

Hi folks, hopefully someone can guide me as to what I might be doing wrong here. I am using the wrapper in a VB.NET project and all has gone well except I can't seem to update group interests, the error "Array is not a valid interest group in grouping .... on the list: ....". This occurs when I call either MailChimpManager.subscribe or MailChimpManager.UpdateMember.

I did try performing a call to MaiChimpManager.GetMemberInfo and then passing the data that was returned by this method straight back to subscribe or UpdateMember but the same error occurs which makes me ponder if there is an underlying issue with the wrapper (it's far more likely my code mind you!).

The code I am using is:

    Public Sub SaveContact(APIKey As String)
        Dim objManager As New MailChimpManager(APIKey)
        Dim objParameter As New Helper.EmailParameter
        Dim objVars As MergeVar = CreateMergeVar()

        'ARE WE ADDING OR UPDATING?
        If ID = "" Then
            'WE ARE ADDING
            objParameter.Email = Email
            strID = objManager.Subscribe(objList.ID, objParameter, objVars,, False).EUId
        Else
            'WE ARE UPDATING
            objParameter.Email = Email
            objParameter.EUId = ID
            strID = objManager.UpdateMember(objList.ID, objParameter, objVars).EUId
        End If
    End Sub


    Private Function CreateMergeVar() As MergeVar
        Dim objVar As New MergeVar
        Dim objGroup As MCList.MCGroup
        Dim objOption As MCList.MCGroup.GroupOption
        Dim bolDoAdd As Boolean
        Dim objDestGroup As Grouping = Nothing
        Dim objInterest As Grouping.GroupInterest

        objVar.Add("FNAME", strFirstName)
        objVar.Add("LNAME", strLastName)

        For Each objGroup In List.Groups
            'CREATE A NEW GROUP IF NECESSARY
            If objVar.Groupings Is Nothing Then objVar.Groupings = New List(Of Grouping)

            'GO THROUGH EACH OPTION IN THE GROUP
            bolDoAdd = False
            For Each objOption In objGroup.Options
                'CREATE A NEW INTEREST
                objInterest = New Grouping.GroupInterest
                objInterest.Interested = objOption.IsSubscribed
                objInterest.Name = objOption.Label

                'ADD THE GROUP IF IT ISN'T ALREADY IN THERE
                If bolDoAdd = False Then
                    bolDoAdd = True
                    objDestGroup = New Grouping
                    objDestGroup.Id = objGroup.ID
                    objDestGroup.GroupNames = New List(Of String)
                    objDestGroup.GroupNames.Add(objGroup.Name)
                    objDestGroup.GroupInterests = New List(Of Grouping.GroupInterest)
                    objDestGroup.GroupInterests.Add(objInterest)

                    objVar.Groupings.Add(objDestGroup)
                Else
                    'WE HAVE ALREADY ADDED THE GROUP SO JUST UPDATE IT
                    objDestGroup.GroupInterests.Add(objInterest)
                End If
            Next
        Next

        Return objVar
    End Function

Thanks in advance! :-)

@shaileshm2390
Copy link

@danesparza, Have you got any solution for this? I am still struggling on this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants