Issue
I had created the mail subscription using mailchimp. The mail id is listed in the lists of mailchimp, but i want to pass the firstname,lastname and want to create a tag while doing the mailchimp subscription. but now i am listing only the mail under my list.. when i am trying to create the tag via postman, the tags are created, but i want to add through api code.
var mailchimpInstance = '***',
listUniqueId = '*********',
mailchimpApiKey = '*****************';
app.post('/signup', function (req, res) {
request
.post('https://' + mailchimpInstance + '.api.mailchimp.com/3.0/lists/' + listUniqueId + '/members/')
.set('Content-Type', 'application/json;charset=utf-8')
.set('Authorization', 'Basic ' + new Buffer('any:' + mailchimpApiKey ).toString('base64'))
.send({
'email_address': req.body.email,
'status': 'subscribed',
'merge_fields': {
"FNAME": req.body.fname,
"LNAME": req.body.lname
}
})
.end(function(err, response) {
if (response.status < 300 || (response.status === 400 && response.body.title === "Member Exists")) {
res.send('Sign Up Success :)');
} else {
res.send('Sign Up Failed :(');
}
console.log(req.body.email);
});
});
This code is for sending the email to the lists..in this code the firstname and lastname is not listed in the lists of mailchimp..and i also need to create tags using this api
Solution
There's a 'tags' body parameter which accepts an array and adds the tags to the mail id. Here's the documentation: https://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#%20
Answered By - Pancasm Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.