MailChimp 3.0 HTTP POST Json Example
Asked Answered
S

1

6

I'm trying to make use of MailChimp's Automation trigger that activates when a subscriber's email ID is posted to an API endpoint:

enter image description here (link)

Following the Workflow instructions, I'm using the following https://us19.api.mailchimp.com/3.0/automations/xxxxxxxxxx/emails/xxxxxxxxxx/queue URL provided via the Campaign.

I can successfully send an authenticated HTTP POST request (using this do_Post() method copied into my codebase), but am faced with a 400 error with a Content-Type: application/problem+json response. My JSON is incorrect and I'm not sure what the JSON should look like to trigger the above event.

I've tried a plethora of different cracks at the JSON - my latest attempt looks like {"unique_email_id":"e063dfcf4g"}. Every attempt at altering the JSON data still is returning me the same error above.

I've been wondering if I possibly need to set some more headers in the POST request, but this is beyond my area of expertise.

I appreciate the help and insights.

Sensor answered 6/12, 2018 at 20:44 Comment(2)
So after much trial and error, apparently the correct JSON is {"email_address":"[email protected]"}. This will make the email member from the campaign's LIST now a SUBSCRIBER to the campaign. Now ... how can I make the trigger fire to send an email to this one person on demand? I thought this is what the 'Triggers an email when a subscriber's email is posted to API endpoint' would do .. but apparently not (it only will fire one time and reject the POST if the member is already a subscriber).Sensor
If you have figured it out, consider answering your own question and posting a different one for the next problem, otherwise it gets confusing quickly.Hadji
E
1

Here's an example of HTTP Basic Auth Postman request:

POST URL:

https://us19.api.mailchimp.com/3.0/automations/********/emails/********/queue
you'll get this when you create api based trigger automation campaign.

Authorization:

enter image description here

generate the api key from mailchimp dashboard and use that as password in postman authorization. put any username.

POST Body:

{"email_address":"[email protected]"}

Read more about mailchimp API : https://mailchimp.com/developer/guides/get-started-with-mailchimp-api-3/


there's also a npm module for this https://npmjs.com/package/mailchimp-api-v3

Exportation answered 8/4, 2020 at 7:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.