1

I am a beginner to DocuSign integration and I want to upload a document sent it to tenants and after they make a digital signature in the mentioned field I have to save it to my app database. What is the best approach for doing this? I have been trying eg-01-node-jwt library as they have mentioned in their documentation. While executing the code after giving rsa key,access token and other credentials I am receiving an error.

Send an envelope with three documents. This operation takes about 15 seconds... checkToken: Using current accessToken

API problem: Status code 404, message body:

{
"success": false,
"message": "Not Found",
"error": {
    "message": "Not Found"
}

Code I have tried

'use strict';

const sendEnvelope = require('./lib/sendEnvelope')
    , listEnvelopes = require('./lib/listEnvelopes')
    , dsConfig = require('./dsConfig.js').config
  ;

async function main() {
  // initialization

  if (! dsConfig.clientId) {
    console.log (`\nProblem: you need to configure this example,
    either via environment variables (recommended) or via the ds_config.js
    file. See the README file for more information\n\n`);
    process.exit();
  }

  console.log ('\nSend an envelope with three documents. This operation takes about 15 seconds...');
  let envelopeArgs = {
        signerEmail: dsConfig.signerEmail,
        signerName: dsConfig.signerName,
        ccEmail: dsConfig.ccEmail,
        ccName: dsConfig.ccName
      }
    , results = await sendEnvelope.sendEnvelope(envelopeArgs);
  console.log (`Envelope status: ${results.status}. Envelope ID: ${results.envelopeId}`);

  console.log ("\nListing envelopes in the account that have changed status in the last 30 days...");
  results = await listEnvelopes.listEnvelopes();
  if (results.envelopes && results.envelopes.length > 2){
    console.log (`Results for ${results.envelopes.length} envelopes were returned. Showing the first two:`);
    results.envelopes.length = 2;
  } else {
    console.log (`Results for ${results.envelopes.length} envelopes were returned:`);
  }
  console.log (`\n${JSON.stringify(results, null, '    ')}`);
  console.log ("\nDone.\n");
}

async function executeMain() {
  try {
    await main();
  } catch (e) {
    let body = e.response && e.response.body;
    if (body) {
      // DocuSign API problem
      if (body.error && body.error == 'consent_required') {
        // Consent problem
        let consent_scopes = "signature%20impersonation",
            consent_url = `https://${dsConfig.authServer}/oauth/auth?response_type=code&` +
              `scope=${consent_scopes}&client_id=${dsConfig.clientId}&` +
              `redirect_uri=${dsConfig.oAuthConsentRedirectURI}`;
        console.log(`\nProblem:   C O N S E N T   R E Q U I R E D

    Ask the user who will be impersonated to run the following url:
        ${consent_url}

    It will ask the user to login and to approve access by your application.

    Alternatively, an Administrator can use Organization Administration to
    pre-approve one or more users.\n\n`)
      } else {
        // Some other DocuSign API problem 
        console.log (`\nAPI problem: Status code ${e.response.status}, message body:
${JSON.stringify(body, null, 4)}\n\n`);
      }  
    } else {
      // Not an API problem
      throw e;
    }
  }
}

// the main line
executeMain();

edit 1

what is the base path?

DsJwtAuth.basePath = "localhost:5000";

Im getting a post request hit on this like this POST /v2/accounts/900be0b4-0eb7-4fcb-b7d0-d3aed6c191a1/envelopes 404

UJ India
  • 588
  • 7
  • 26

1 Answers1

0

Sorry you're having this problem. Did you start by downloading the repository version of the code example from https://github.com/docusign/eg-01-node-jwt ?

In order to do more debugging, you'll need to find out where the error is being raised from by using standard Node.js debugging techniques.

Larry K
  • 42,977
  • 12
  • 82
  • 121
  • returned from this line await sendEnvelope.sendEnvelope(envelopeArgs); when I commented the abouve mentioned it throwed at await listEnvelopes.listEnvelopes(); – UJ India Jan 24 '20 at 08:36
  • what is the base path ? DsJwtAuth.basePath = "http://localhost:5000"; Im getting a post request hit on this like this POST /v2/accounts/900be0b4-0eb7-4fcb-b7d0-d3aed6c191a1/envelopes 404 4.967 ms - 71 – UJ India Jan 24 '20 at 08:54
  • 1
    Please **edit your question** to add more information. The base_uri for making API calls in the demo environment is https://demo.docusign.net/restapi – Larry K Jan 24 '20 at 09:22
  • Yes, I have changed after reding this https://stackoverflow.com/questions/46650699/need-docusign-api-endpoint and issue got fixed when I changed http to https://demo.docusign.net/restapi. Ill edit this post and kindly post the answer above mentioned comment as answer.Thanks – UJ India Jan 24 '20 at 09:45