Edward Gizbreht
Edward Gizbreht

Reputation: 306

mailchimp unsubscribe with node js server

i have a problem with mailchimp unsubscribe process. Please can you provide me the way for unsubscribe process. How exactly put in unsubscribe list and what files i should request. And how i know the differences that the email should be put in unsubscribe list.

mailchimp.post('/lists/{id}', {
      email_address : "[email protected]"
    })
      .then(function(results) {
        console.log(results)
      })
      .catch(function (err) {
        console.log(err)
      });

Response error

{ Error: The resource submitted could not be validated. For field-specific details, see the 'errors' array.
    at Request._callback (/Users/Gizbreht/Desktop/myofer-mailer-express/node_modules/mailchimp-api-v3/index.js:506:30)
    at Request.self.callback (/Users/Gizbreht/Desktop/myofer-mailer-express/node_modules/request/request.js:187:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/Gizbreht/Desktop/myofer-mailer-express/node_modules/request/request.js:1126:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/Users/Gizbreht/Desktop/myofer-mailer-express/node_modules/request/request.js:1046:12)
    at IncomingMessage.g (events.js:291:16)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
  type: 'http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/',
  title: 'Invalid Resource',
  status: 400,
  detail: 'The resource submitted could not be validated. For field-specific details, see the \'errors\' array.',
  instance: '',
  errors: 
   [ { field: '',
       message: 'Required fields were not provided: members' } ] }

Upvotes: 0

Views: 917

Answers (1)

Edward Gizbreht
Edward Gizbreht

Reputation: 306

mailchimp.post('/lists/{id}', {
    "members" : [{"email_address": email, "status": "unsubscribed"}],"update_existing":true
})
.then(function(results) {
    console.log(results)
})
.catch(function (err) {
    console.log(err)
});

Upvotes: 1

Related Questions