Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MailChimp 3.0 HTTP POST Json Example

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.

like image 773
VILLAIN bryan Avatar asked Dec 06 '18 20:12

VILLAIN bryan


1 Answers

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

like image 178
GorvGoyl Avatar answered Oct 03 '22 08:10

GorvGoyl