FormiIt with Mailchimp subscribe to list not working

Was trying to get the same extra working and also ran into the Invalid Resource: The resource submitted could not be validated. For field-specific details, see the ‘errors’ array. error.

The plugin does a very poor job of error handling and passing API errors back into view, but with some debugging (read: editing the plugins’ code to dump errors to screen) I finally managed to track down a more useful error:

array(6) {
  ["type"]=> string(77) "http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/" 
  ["title"]=> string(16) "Invalid Resource" 
  ["status"]=> int(400) 
  ["detail"]=> string(98) "The resource submitted could not be validated. For field-specific details, see the 'errors' array." 
  ["instance"]=> string(36) "<..>" 
  ["errors"]=> array(1) { 
    [0]=> array(2) { 
      ["field"]=> string(12) "merge_fields" 
      ["message"]=> string(36) "This value should be of type object." 
    } 
  } 
}

That indicates a problem with the merge_fields being sent, which upon further inspection was being passed as empty:

array(3) {
  ["email_address"]=> string(16) "[email protected]" 
  ["merge_fields"]=> array(0) { } 
  ["status"]=> string(7) "pending" 
} 

This appears to have been due to the &mailchimpFields property on the FormIt call which only contained the email in my case, just like the code snippet in the opening post here: &mailchimpFields=`email=EMAIL`

After updating that to also include another merge field (&mailchimpFields=`email=EMAIL,name=FNAME` ), the subscribe finally started to work.

Another undocumented thing to note is that the API Key needs to be in the format <key>-<dc> where <dc> is the datacenter, like us2. The API Key I was originally provided was incorrect and missed the DC causing it to not work as well. Again, the plugin does a poor job of communicating such errors, so that takes some digging :confused:

1 Like