Shoaib
Shoaib

Reputation: 21

Cannot get envelopeId from envelopesApi.createEnvelope by using docusign-esign

I'm working with DocuSign eSignature API and following this link https://www.docusign.com/developer-center/api-overview#post-go-live

everything was going great but when I tried to get envelopeId this function didn't return anything not even error

var envelopesApi = new docusign.EnvelopesApi();
 envelopesApi.createEnvelope(loginAccounts[0].accountId, envDef, null, function(error, envelopeSummary, response) {
if (error) {
  console.log('Errors: ' + JSON.stringify(error));
  return next(error);
}
if (envelopeSummary) {
  console.log("EnvelopeSummary:" + JSON.stringify(envelopeSummary));
  const envelopeId = envelopeSummary.envelopeId;
}
});

Upvotes: 1

Views: 356

Answers (3)

Shoaib
Shoaib

Reputation: 21

I was passing data like this

var envelopesApi = new docusign.EnvelopesApi();
envelopesApi.createEnvelope(loginAccounts[0].accountId, envDef, null, 
function(error, envelopeSummary, response)

but when I looked in node_module/docusign-esign I found this

this.createEnvelope = function(accountId, opts, callback) {
opts = opts || {};
var postBody = opts['envelopeDefinition'];

I used this code to pass data in parameters

 var envelopesApi = new docusign.EnvelopesApi();
 var data = [];
 data['envelopeDefinition'] =  envDef;
 envelopesApi.createEnvelope(loginAccounts[0].accountId, data,  
 function(error, envelopeSummary, response)

It returned desired envelopeSummary

Upvotes: 1

Amit K Bist
Amit K Bist

Reputation: 6818

You can enable API logging in your DS Demo account by following API Logging Steps. Once API logging is enabled then please capture and download the logs which will show the request/response (or any error) and will help you in debugging the issue.

Upvotes: 1

Frederic
Frederic

Reputation: 2065

It's possible that the "CreateEnvelope" returned an exception, you could add a try/catch block to see if it's the case, it might be good for your code in general in case of future errors :

try
{
      EnvelopeSummary summary =
      envelopesApi.SendEnvelope(oginAccounts[0].accountId, envDef, null, function(error, envelopeSummary, response);
}
catch (Exception ex)
{
    string error = ex.Message;
    Console.WriteLine(error);
}

Upvotes: 1

Related Questions