简体   繁体   中英

Sendgrid (Node JS) add contact to custom Marketing list

I'm trying to add a contact to the marketing list with Sendgrid Node JS

 var request = require("request");

      var options = { method: 'PUT',
        url: 'https://api.sendgrid.com/v3/marketing/contacts',
        headers: { authorization: 'Bearer myAPIKEY' },
        body: '{"contacts":[{"email": "myMail@gmail.com","unique_name":"myName"}]}' };

      request(options, function () {
      });

Everything works, but I would also like to add the contact to a specific list. I read the documentation and it says I need to add the id of the contact.

Where can I find that or How can I add a contact to a specific list?

Thank you!

So I read the documentation, you can put a list ID within the body of the request, like this:

"list_ids":["theidofyourlist"], "contacts" ....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM