MailChimp 3.0 HTTP POST Json Example

♀尐吖头ヾ 提交于 2020-04-13 05:43:09

问题


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:

(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.


回答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:

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

POST Body:

{"email_address":"tigerking@gmail.com"}

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



来源:https://stackoverflow.com/questions/53659401/mailchimp-3-0-http-post-json-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!