Interests group update doesn't work

Sep 15, 2010 at 12:26 PM

When creating a new subscriber and adding groups it works fine using this code:
entry.Add("Interests", "Readers")

But, when updating an existing subscriber to change the Interests group, changes are not updated on MC.

These settings are also used:
  input.parms.replace_interests = True
  input.parms.update_existing = True

Any ideas why?

Coordinator
Sep 15, 2010 at 2:18 PM

I'm afraid that isn't enough info to give you a good answer...

1) What api method are you using?  listSubscribe(), or listBatchSubscribe() ?  -- just in case I need to look at a coding issue

2) What error message, if any, is being returned in api_ErrorMessages?  

3) Show me a more complete code block -- leaving out your apikey. Particularly how you're assigning the merge_vars, including the groupings of course

4) The most common scenario is that the grouping id or grouping name is incorrect, if you're using the groupings method of assignment [recommended].

5) The other thing is that if "Interests" is really a name of a group of yours, you might want to change that name.  It's been a while, but it seems that at one time, way back when there was only interest groups - not groupings, I had a group name of 'Interests' and that caused me grief because MC treats the name as a special key. I've avoided that name ever since, so I don't know whether that still causes problems after the latest changes by MC.

David

 

Sep 15, 2010 at 6:20 PM

Hi David,

 

1) We tested with both listSubscribe and listBatchSubscribe

2) None, "succes: 1" (if updating 1 subscriber :) )

3)

 Dim input As New listBatchSubscribeInput
        input.api_Validate = True
        input.api_AccessType = EnumValues.AccessType.Serial
        input.api_OutputType = EnumValues.OutputType.JSON

        input.parms.apikey = ***
        input.parms.id = ***
        input.parms.double_optin = False
        input.parms.replace_interests = True
        input.parms.update_existing = True

        Dim batch As List(Of Dictionary(Of String, Object)) = New List(Of Dictionary(Of String, Object))

        For Each s As Subscriber In sublist
            Dim entry As Dictionary(Of String, Object) = New Dictionary(Of String, Object)

            entry.Add("EMAIL", s.Email)
            entry.Add("INTERESTS", "Readers")

            batch.Add(entry)
        Next
       
        input.parms.batch = batch

        Dim cmd As listBatchSubscribe = New listBatchSubscribe(input)
        Dim output As listBatchSubscribeOutput = cmd.Execute()

 

4) The same code works fine when the subscriber is new  (no update)

5) same as 4)

 

Thanks for your effort!

Coordinator
Sep 16, 2010 at 4:22 PM

OK - I thought your code looked OK (although my VB is pretty rusty) and I went and ran some tests (my code below) on my MC Dev account (using listSubscribe for clarity)and all worked fine; add & update of the subscriber including assigning multiple interests.

Without seeing how you have the groups setup on MailChimp, that leads me to a few questions;

1) Can you double check the version of the wrapper .dll ? PerceptiveMCAPI.dll should be v1.2.4.3  -- you probably are, but I just want to eliminate the easy stuff.

2)  How are your interest groups setup?  If you are using multiple interest groups, you should use the GROUPINGS option.

3) can you post, or send offline, a screen shot of your group setup from the web app, or the output from a listInterestGroupings() api call -- that might give a clue.

 

David


   Public Sub listSubscribe_method()

      Dim input As listSubscribeInput = New listSubscribeInput()

      ' any directive overrides 
      input.api_Validate = False
      input.api_AccessType = EnumValues.AccessType.Serial
      input.api_OutputType = EnumValues.OutputType.JSON
      '  method parameters
      input.parms.apikey = MCAPISettings.default_apikey
      input.parms.id = "mylist"
      input.parms.double_optin = False
      input.parms.replace_interests = True
      input.parms.update_existing = True
      '
      input.parms.email_address = "dbm@dbm.com"
      input.parms.email_type = EnumValues.emailType.html
      '
      input.parms.merge_vars = New Dictionary(Of String, Object)
      input.parms.merge_vars.Add("INTERESTS", "Readers, Writers")

      ' execution
      Dim cmd As listSubscribe = New listSubscribe(input)
      Dim output As listSubscribeOutput = cmd.Execute()

      Label1.Text = output.result.ToString
      GridView1.DataSource = output.api_ErrorMessages
      GridView1.DataBind()

   End Sub

 

Sep 23, 2010 at 10:40 AM

When you change listSubscribeInput into listBatchSubscribeInput the merge_vars are not available.

Shouldn't this work instead? 

For Each s As Subscriber In sublist 

 Dim entry As Dictionary(Of String, Object) = New Dictionary(Of String, Object) 

 entry.Add("EMAIL", s.Email) 
 entry.Add("INTERESTS", "Readers") 
 batch.Add(entry)

Next

1) yes, latest version 1.2.4.3
2) yes, there are multiple groups / do you have any samples on using this in code?
 Regards,
Sven

 

Sep 24, 2010 at 7:58 AM

I've just done a batch-import of NEW contacts using the code in previous post and the group is set correctly.

 

Sven

Coordinator
Sep 27, 2010 at 5:39 PM

The exact same code in the wrapper is executed regardless of it being a new subscriber or updating of an existing subscriber -- so this pretty much enforces my suspicion that it is a data/setup issue.

If you want me to help you track it down, I need the previous information I asked for...

3) can you post, or send offline, a screen shot of your group setup from the web app, or the output from a listInterestGroupings() api call -- that might give a clue.

The way the groups & groupings work is defined in the MC Api Documentation -- although the names are somewhat confusing.

There is a sample (in C#) in the TestCode.aspx.cs -- the relevant section below.  
One other thing to keep in mind -- even if an error wasn't reported in the errors for the subscribers not updated, MailChimp does a 'silent' fail on invalid mergevars that aren't required. 

      //--------------------------------------------------------------  
      public void test_listBatchSubscribe()
      {
         lblTestName.Text = "listBatchSubscribe";

         // input parameters
         listBatchSubscribeInput input = new listBatchSubscribeInput();
         input.api_AccessType = EnumValues.AccessType.Serial;       // access
         input.api_OutputType = EnumValues.OutputType.JSON;       // output
         input.api_MethodType = MethodType;        // method
         input.api_EncodeRequest = EncodeRequest;  // encode
         input.api_Validate = false;     // validate
         //
         input.parms.apikey = "Your-apikey";

         input.parms.id = "YourListId";

         input.parms.double_optin = false;
         input.parms.replace_interests = MCAPISettings.default_listSubscribe_replace_interests;
         input.parms.update_existing = true;

         // ------------------------------ address
         List<Dictionary<string, object>> batch = new List<Dictionary<string, object>>();
         Dictionary<string, object> entry = new Dictionary<string, object>();
         entry.Add( "EMAIL", "zzz@dbm.com" ); entry.Add( "EMAIL_TYPE", "text" ); entry.Add( "FNAME", "Lidia" );
         entry.Add( "username", "liduser" );
         entry.Add( "homeadr", "215 Lakeside  A  Ajijic  JAL  12345  MX" );
         batch.Add( entry );

         // ------------------------------ address array & date
         entry = new Dictionary<string, object>();
         //
         DateTime dt = DateTime.Now;
         Dictionary<string, object> address = new Dictionary<string, object>();
         address.Add( "addr1", "225 Lakeside" );
         address.Add( "addr2", "A" );
         address.Add( "city", "Ajijic" );
         address.Add( "state", "JAL" );
         address.Add( "zip", "12345" );
         address.Add( "country", "MX" );
         //
         entry.Add( "EMAIL", "xxx@dbm.com" ); entry.Add( "EMAIL_TYPE", "html" ); entry.Add( "FNAME", "David" );
         entry.Add( "mydate", dt );
         entry.Add( "homeadr", address );
         batch.Add( entry );
         // --------------------------------------------- interest groupings
         entry = new Dictionary<string, object>();
         entry.Add( "EMAIL", "yyy@dbm.com" ); entry.Add( "EMAIL_TYPE", "html" ); entry.Add( "FNAME", "Guy" ); entry.Add( "LNAME", "Britain" );
         entry.Add( "username", "gbritain" );
         entry.Add( "homeadr", "409 Monroe Street  Carrolton  NY  14617  US" );
         // ---------------------
         List<interestGroupings> groupings = new List<interestGroupings>();
         //
         interestGroupings ig = new interestGroupings { id = 33, name = "", groups = new List<string> { "dogs, cats" } };
         groupings.Add( ig );
         //
         ig = new interestGroupings();
         ig.id = 0; ig.name = "Work Interests"; ig.groups = new List<string> { "Surveys", "Integration" };
         groupings.Add( ig );
         //
         entry.Add( "groupings", groupings );
         batch.Add( entry );
         // -------------------------
         input.parms.batch = batch;
         //-------------------------------------------------------------- 
         // execution
         listBatchSubscribe cmd = new listBatchSubscribe( input );
         listBatchSubscribeOutput output = cmd.Execute();

         // format output 
         show_listBatch1.Display( output );
         showResults( output.api_Request, output.api_Response,
            output.api_ErrorMessages, output.api_ValidatorMessages );
      }