Search code examples
javascriptnode.jspostmanmailchimp

Why got error Invalid_Key from the metadata Api of MailChimp?


I have tried the API(/metadata/list) of mailChimp as recommended by the official documentation through postman but always got the same error of Invalid_Key. I have getting key from the mailchimp account and it's active right now. Is anyone know that there is some tricky part to call the MailChimp Api's through postman?

Error Response of Postman:

 {
        "status": "error",
        "code": -1,
        "name": "Invalid_Key",
        "message": "Invalid API key"
        "Status Code: 500
 }

Official MailChimp Documentation Link

And I have tried the mailchimp client transactional nodeJS code as well which is as following but still got same error as thorugh postman.

const mailchimp = require('@mailchimp/mailchimp_transactional')('API-KEY');

async function callPing() {
    const response = await mailchimp.metadata.list();
    console.log(response);
}

callPing();

mailchimp-transactional-node


Solution

  • Update

    1. you might be using the API key created from Mailchimp and not mandrillapp.

    2. Mandrill is an add on in Mailchimp, so you are authenticating yourself with mandrill and mandrill will authenticate you to Mailchimp account. So you have to create api key from mandrill and not mailchimp.

    Step to create the key:

    1. Login to your mailchimp account and click Transaction "try our demo", then you will see below Launch button . Click on it:

    enter image description here

    1. Click on continue to mandrill and once you are in mandrillaccount ignore what ever you see on screen. Click on setting and click Add or new api key:

    enter image description here

    1. now use this in your request:

    enter image description here

    old answer

    curl -X POST \
      https://mandrillapp.com/api/1.0/metadata/list \
      -d '{"key":""}'
    

    This is the curl for the specific request ,as key is send as body you have to use body>raw>json

    And use { "key" : "value"}

    You don't have to pass it through authorization.

    Postman benefits

    In postman this process can be made easy by clicking

    Import > using curl and pasting the curl command that is provided as example

    It will create the equalent request for you automatically

    Generation of code from postman

    You can click the link named as code near to the send button, to create code in any language from postman request