在进行api调用时,Docusign遗留标头错误
尝试使用Docusign API的传统标头时收到错误消息。
这是我的代码
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'); });
这是错误
{ errorCode: 'INVALID_TOKEN_FORMAT', message: 'The security token format does not conform to expected schema.' }
您传递的authheader是不正确的。 尝试下面的代替。 SDK文档在这里
// 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); });