【问题标题】:NodeJS Docusign eg-01-node-jwt- API Problem status 404NodeJS Docusign eg-01-node-jwt- API 问题状态 404
【发布时间】:2020-01-24 06:26:09
【问题描述】:

我是 DocuSign 集成的初学者,我想上传一个发送给租户的文档,在他们在上述字段中进行数字签名后,我必须将其保存到我的应用程序数据库中。这样做的最佳方法是什么?正如他们在文档中提到的那样,我一直在尝试 eg-01-node-jwt 库。在提供 rsa 密钥、访问令牌和其他凭据后执行代码时,我收到一个错误。

发送一个包含三份文件的信封。此操作大约需要 15 秒... checkToken:使用当前的 accessToken

API 问题:状态码 404,消息正文:

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

我尝试过的代码

'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();

编辑 1

什么是基本路径?

DsJwtAuth.basePath = "localhost:5000";

我收到了这样的帖子请求 POST /v2/accounts/900be0b4-0eb7-4fcb-b7d0-d3aed6c191a1/envelopes 404

【问题讨论】:

    标签: javascript node.js docusignapi docusigncompositetmplts


    【解决方案1】:

    抱歉,您遇到了这个问题。您是从https://github.com/docusign/eg-01-node-jwt 下载代码示例的存储库版本开始的吗?

    为了进行更多调试,您需要使用标准 Node.js 调试技术找出错误是从哪里引发的。

    【讨论】:

    • 从这一行返回 await sendEnvelope.sendEnvelope(envelopeArgs);当我评论上面提到的它时,它抛出了 await listEnvelopes.listEnvelopes();
    • 基本路径是什么? DsJwtAuth.basePath = "localhost:5000";我收到这样的帖子请求 POST /v2/accounts/900be0b4-0eb7-4fcb-b7d0-d3aed6c191a1/envelopes 404 4.967 ms - 71
    • 编辑您的问题以添加更多信息。在demo环境中调用API的base_uri是demo.docusign.net/restapi
    • 是的,我在更改此stackoverflow.com/questions/46650699/need-docusign-api-endpoint 后已更改,当我将 http 更改为 demo.docusign.net/restapi 时问题已解决。我会编辑这篇文章,并将上面提到的答案作为答案发布。谢谢
    猜你喜欢
    • 2020-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-03
    • 2017-08-16
    • 1970-01-01
    • 2021-04-26
    相关资源
    最近更新 更多