Closed johngirvin closed 10 years ago
Is List<InterestGrouping>
the correct type for the field SubscribeMethod.merge_vars.groupings
?
Hi John,
Is List
the correct type for the field SubscribeMethod.merge_vars.groupings ?
No.
InterestGrouping is supposed to be used in the result of the "listInterestGroupings" method (API v1.3).
Apparently, the "/lists/subscribe" method uses different format for the group names. Perhaps, you should create and use a class like this:
public class MyInterestGrouping extends MailChimpObject {
@Field
public Integer id;
@Field
public String name;
@Field
public List<String> groups;
}
Thanks for the clarification. I'm using my own class as above and it's working.
SubscribeMethod (/lists/subscribe) encodes the member's Interest Groups as an array of Interest Group objects, but the API in 2.0 is expecting a simple array of Interest Group names as strings.
(code edited for brevity)
Based on the above, the JSON sent to the server contains (array of Interest Group objects):
This results in an API error:
com.ecwid.mailchimp.MailChimpException: API Error (270): "Array" is not a valid Interest Group in Grouping "Email Preferences" on the list: ...
Modifying the JSON to the following allows the request to complete successfully and modify the member's groups.
As a workaround I am using a custom Interest Grouping mergevar that has a simple List for the
groups
field.