3

I have a fairly simple setup, wanted to create a simple envelope used the node-DocuSign-examples client. https://github.com/docusign/code-examples-node

I am getting jwt token from the getToken method( Completed all the user consent issues.) But CreateEnvelope Api from Docusign API is returning exports {} as a response.

Simple Function from node example:

eg001EmbeddedSigning.worker = async (args) => {
    let dsApiClient = new docusign.ApiClient();
    dsApiClient.setBasePath(args.basePath);
    dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + args.accessToken);
    let envelopesApi = new docusign.EnvelopesApi(dsApiClient)
      , results = null;

    // Step 1. Make the envelope request body
    let envelope = makeEnvelope(args.envelopeArgs)

    // Step 2. call Envelopes::create API method
    // Exceptions will be caught by the calling function
    results = await envelopesApi.createEnvelope(args.accountId, {envelopeDefinition: envelope});

    let envelopeId = results.envelopeId;
    console.log(`Envelope was created. EnvelopeId ${envelopeId}`);

    // Step 3. create the recipient view, the Signing Ceremony
    results = await envelopesApi.createRecipientView(args.accountId, envelopeId);

    return ({envelopeId: envelopeId})
}

function makeEnvelope(args){
    let docPdfBytes;
    docPdfBytes = fs.readFileSync(path.resolve(demoDocsPath, pdf1File));
    let env = new docusign.EnvelopeDefinition();
    env.emailSubject = 'Please sign this document';
    
    let doc1 = new docusign.Document()
      , doc1b64 = Buffer.from(docPdfBytes).toString('base64')
      ;

    doc1.documentBase64 = doc1b64;
    doc1.name = 'Lorem Ipsum';
    doc1.fileExtension = 'pdf';
    doc1.documentId = '3';
    env.documents = [doc1];

    let signer1 = docusign.Signer.constructFromObject({
        email: args.signerEmail,
        name: args.signerName,
        clientUserId: args.signerClientId,
        recipientId: 1
    });

    let signHere1 = docusign.SignHere.constructFromObject({
          anchorString: '/sn1/',
          anchorYOffset: '10', anchorUnits: 'pixels',
          anchorXOffset: '20'})
      ;

    let signer1Tabs = docusign.Tabs.constructFromObject({
      signHereTabs: [signHere1]});
    signer1.tabs = signer1Tabs;

    let recipients = docusign.Recipients.constructFromObject({
      signers: [signer1]});
    env.recipients = recipients;

    env.status = 'sent';

    return env;
}
Uday Kumar
  • 41
  • 5

1 Answers1

1

I suggest that you first download and install the overall Node.js example and get it working. Then compare it to your code to understand where the problem is.

At first glance your code looks fine, so something more subtle is going on.

Also, when you requested consent for your integration key, did you request both the signature and impersonation scopes?

Added

Anytime a document is not being displayed correctly, here are the steps to debug:

  1. Try using the DocuSign web tool to create an envelope that includes the suspect document. If the envelope and document work correctly, then the problem is with your software application, not with the document itself. In this case check that you're processing the PDF as a binary file.
  2. If the document doesn't look right (or is blank) when you use the DocuSign web tool, then the document is at fault. If it is a PDF, try opening it with a PDF analysis tool and see if anything is funky. You can also try a less complicated document.
Larry K
  • 47,808
  • 15
  • 87
  • 140
  • I downloaded and got sample code working, even signed and generated some envelopes with example code, and then I tried to integrate into our application. I got the consent for both the scopes `signature` and `impersonation` - that's how I was able to get the Session token. I am passing a local document, even if the document does not contain any `\sn1\` tags, it should atleast create envelope and return envelope ID. – Uday Kumar Jul 08 '20 at 11:27
  • Please **edit** your question to include an [API log](https://support.docusign.com/en/guides/ndse-user-guide-api-request-logging). – Larry K Jul 08 '20 at 11:54