简体   繁体   中英

Docusign legacy header error when making api call

I am receiving an error when attempting to use legacy headers for Docusign API.

here is my code

request({
    headers: {
        "X-DocuSign-Authentication": [{
            "Username": "zabie@toplevelstaging.com",
            "Password": "xxxxxxxx",
            "IntegratorKey": "xxxxxxxxxxx-11xxx2f567xxxx0dbxxxx2d"
        }]
    },
    url: "https://demo.docusign.net/restapi/v2/accounts/3465212/envelopes",
    json: true, // <--Very important!!!
    body: data,
    method: "POST",

}, function (error, response, body) {
    console.log(response.body);
});
console.log(data[0].templateRoles[0].tabs.textTabs[0].value);
console.log(data[0].templateRoles[0].roleName);
res.redirect('/contracts');

});

Here is the error

{
    errorCode: 'INVALID_TOKEN_FORMAT',
    message: 'The security token format does not conform to expected schema.'
}

The authheader you are passing is incorrect. Try the following instead. SDK Documentation here

// create JSON formatted auth header
var creds = JSON.stringify({
  Username: "zabie@toplevelstaging.com",
  Password: "xxxxxxx",
  IntegratorKey: "xxxxxxxxxxx-11xxx2f567xxxx0dbxxxx2d"
});


request({
   headers: { "X-DocuSign-Authentication": creds },
   url: "https://demo.docusign.net/restapi/v2/accounts/3465212/envelopes",
   json: true, // <--Very important!!!
   body: data,
   method: "POST",
   }, function (error, response, body) {
    console.log(response.body);
});

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