问题描述
mailerLite是一种SaaS,用于管理联系人并发送电子邮件。我正在尝试使用他们的API将HTML内容添加到我的帐户中。
他们的API建立在HTTP之上,并且是RESTful的。根据他们的文档here,我可以创建一个广告系列并添加HTML内容。有一个PHP和cURL示例:
我正在使用R,因此我像这样添加了type = regular
广告系列:
response <- POST("https://api.mailerlite.com/api/v2/campaigns",add_headers("X-MailerLite-ApiKey" = apiKey),body = list(
"type" = "regular","segments" = 1291259,"subject" = "New","from" = "<email>","from_name" = "<name>"
))
这有效。 当我尝试添加HTML内容时,请尝试使用其cURL示例替换我的api-key并将广告系列ID放入URL。
curl -X PUT "https://api.mailerlite.com/api/v2/campaigns/1291259/content" \
-d '{
"html": "<h1>Title</h1><p>Content</p><p><small><a href=\"{$unsubscribe}\">Unsubscribe</a></small></p>","plain": "Your email client does not support HTML emails. Open newsletter here: {$url}. If you do not want to receive emails from us,click here: {$unsubscribe}"
}' \
-H "Content-Type: application/json" \
-H "X-MailerLite-ApiKey: <api-key>”
这导致:
{"error":{"code":422,"message":"Type of mail that belongs to campaign must be custom_html"}}
即使custom_html
未定义为类型,我也尝试这样做。
curl -X PUT "https://api.mailerlite.com/api/v2/campaigns/1291259/content" \
-d '{
"custom_html": "<h1>Title</h1><p>Content</p><p><small><a href=\"{$unsubscribe}\">Unsubscribe</a></small></p>",click here: {$unsubscribe}"
}' \
-H "Content-Type: application/json" \
-H "X-MailerLite-ApiKey: <api-key>”
现在错误是:{"error":{"code":422,"message":"HTML template is not provided"}}~/:
我认为我发送的HTML只是模板。我想念什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)