ActiveCampaign / activecampaign-api-nodejs

Node.js wrapper for the ActiveCampaign API
MIT License
39 stars 36 forks source link

Array of tags #20

Closed btoone closed 8 years ago

btoone commented 8 years ago

When I pass an array for tags the result is a little messed up. Am I using this correctly?

screen shot 2016-04-14 at 9 05 35 pm
var data = {
  email: this._user.email,
  tags: ['foo','bar']
}
ac.api('contact/tag_add', data).then(function (result) {
  console.log("DEBUG: success", result)
}, function (result) {
  console.log("DEBUG: error", result)
})
molinto commented 8 years ago

Hey @caspyin, this is what we use to record NPS Scores:

var acTagAdd, contact;
acTagAdd = new require("activecampaign")(ac_api_host, ac_api_key);
acTagAdd.version(1);
acTagAdd.debug = false;

contact = {
     'id': contactJSON.acId,
     'tags[0]': 'nps_score_' + contactJSON.score,
     'tags[1]': 'nps_type_' + contactJSON.scoreType
 };

acTagAdd.api("contact/tag/add", contact).then(function (result) {
     if (result.success) {
           console.log('Bingo!);
     } else {
          console.log('Failed to add tag to contact in AC');
     }
}, function (result) {
     console.log('Error with adding tag to contact in AC');
});
btoone commented 8 years ago

Using tags[0] worked. Thank you very much @molinto