I'm trying to create a Mailchimp list using Mailchimps API (v3) and the REST Client gem. I've got this working correctly for retrieving list names and ids. However, I'm getting a 401 Unauthorized - API Key Missing
response for the creation of a list. I think my post request is malformed but I'm having trouble indentifying where I'm going wrong. My code looks like this:
params_hash = {
name: "#{territory}",
contact: {
company: "Company",
address1: "Address",
city: "City",
state: "State",
zip: "0000",
country: "US"
},
permission_reminder: "You are receiving this email because....",
campaign_defaults: {
from_name: "From Name",
from_email: "contact@contact.com",
subject: "Subject",
language: "en"
},
notify_on_subscribe: "contact1@contact.com",
notify_on_unsubscribe: "contact1@contact.com",
email_type_option: true,
apikey: mailchimp_key
}
RestClient.post("#{mailchimp_url}/lists", { params: params_hash }) { |response, request, result, &block|
}