Q:

Getting error from mailsnake when trying to set groupings

I'm trying to use Mailchimp's listSubscribe to subscribe a user to a list.  The list has a single group (id = 9917, name = 'I am a ...') with these options: diner, food service operator.  My goal is to add the user as a food service operator.  Here's my code:
ms.listSubscribe(
    id=settings. MAILCHIMP_NEWSLETTER_LIST_ID,
    email_address=self.user.email,
    merge_vars={'FNAME': self.user.first_name,
        'LNAME': self.user.last_name,
        'GROUPINGS': 
            {'id': 9917,
            'groups': 'food service operator',}},
    double_optin=False,
    update_existing=True,
)  

When I run this, I get this error:

ListInvalidInterestGroupException: "" is not a valid Interest Grouping
  name for the list: (TEST) Newsletter

If I remove the groupings stuff, this works perfectly (though the user isn't added to the grouping).  Also, I get this same error if I try to use a garbage id. To ensure that I'm using the right ID, I ran 
In [4]: ms.listInterestGroupings(id=settings. MAILCHIMP_NEWSLETTER_LIST_ID)
Out[4]: 
[{'display_order': '0',
  'form_field': 'checkboxes',
  'groups': [{'bit': '1',
    'display_order': '1',
    'name': 'food service operator',
    'subscribers': 0},
   {'bit': '2', 'display_order': '2', 'name': 'diner', 'subscribers': 0}],
  'id': 9917,
  'name': 'I am a ...'}]

So, it seems this should be working properly.  Any thoughts on why it's not? 

A:

I found the answer in the Mailchimp API google groups. 
Unfortunately, the problem was a result of me not reading the documentation well enough.  GROUPINGS should be an array of dicts.  Here's the corrected code:
ms.listSubscribe(
    id=settings. MAILCHIMP_NEWSLETTER_LIST_ID,
    email_address=self.user.email,
    merge_vars={'FNAME': self.user.first_name,
        'LNAME': self.user.last_name,
        'GROUPINGS': [
            {'id': 9917,
            'groups': 'food service operator',},]},
    double_optin=False,
    update_existing=True,
)  

