代码之家  ›  专栏  ›  技术社区  ›  Scott Cowan

docusign API中的收件人无效

  •  0
  • Scott Cowan  · 技术社区  · 6 年前

    我正在尝试将docusign签名页嵌入到网站中。但我得到了这个错误

    Message=Error calling CreateRecipientView: {
      "errorCode": "UNKNOWN_ENVELOPE_RECIPIENT",
      "message": "The recipient you have identified is not a valid recipient of 
      the specified envelope."
    }
    

    我正在使用。Net nuget客户端,下面是我使用的代码(注意,我更改了GUID和电子邮件)

    证明…是真实的

    string userId = "0570b3da-652e-4040-842e-65a0e6fc8133"; // use your userId (guid), not email address
    string integratorKey = "cf73e7bb-e05d-4ce9-9cea-ac065dc894ac";
    string host = "https://demo.docusign.net/restapi";
    
    ApiClient apiClient = new ApiClient(host);
    
    string username = "my@email.com";
    string password = "[password]";
    
    // initialize client for desired environment (for production change to www)
    Configuration.Default.ApiClient = apiClient;
    
    // configure 'X-DocuSign-Authentication' header
    string authHeader = "{\"Username\":\"" + username + "\", \"Password\":\"" + password + "\", \"IntegratorKey\":\"" + integratorKey + "\"}";
    Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader);
    

    查找帐户id

    这是 example code

    // we will retrieve this from the login API call
    string accountId = null;
    
    AuthenticationApi authApi = new AuthenticationApi(apiClient.Configuration);
    LoginInformation loginInfo = authApi.Login();
    
    //find the default account for this user
    foreach (LoginAccount loginAcct in loginInfo.LoginAccounts)
    {
        if (loginAcct.IsDefault == "true")
        {
            accountId = loginAcct.AccountId;
    
            string[] separatingStrings = { "/v2" };
    
            // Update ApiClient with the new base url from login call
            apiClient = new ApiClient(loginAcct.BaseUrl.Split(separatingStrings, StringSplitOptions.RemoveEmptyEntries)[0]);
            break;
        }
    }
    

    从模板创建信封

    EnvelopeDefinition envDef = new EnvelopeDefinition();
    TemplateRole tRole = new TemplateRole();
    tRole.Email = "recipient@email.com";
    tRole.RoleName = "Leaseholder";
    tRole.ClientUserId = tRole.Email;
    
    List<TemplateRole> rolesList = new List<TemplateRole> { tRole };
    
    envDef.TemplateRoles = rolesList;
    envDef.TemplateId = "2504e3f0-f4d9-4eca-9fd3-3b26cfd6c086";
    
    RecipientViewRequest viewOptions = new RecipientViewRequest()
    {
        ReturnUrl = "http://localhost:64202/home/winning",
        ClientUserId = tRole.Email,  // must match clientUserId of the embedded recipient
        AuthenticationMethod = "email",
        UserName = tRole.Email,
        Email = tRole.Email
    };
    
    EnvelopesApi envelopesApi = new EnvelopesApi();
    var summary = envelopesApi.CreateEnvelope(accountId, envDef);
    var receipients = envelopesApi.ListRecipients(accountId, summary.EnvelopeId);
    ViewUrl viewUrl = envelopesApi.CreateRecipientView(accountId, summary.EnvelopeId, viewOptions);
    
    return Content($"<h2>hmm</h2><iframe width=\"100%\" height=\"100%\" src=\"{viewUrl.Url}\"/>");
    

    模板上的收件人

    enter image description here

    收件人

    {
    "agents": [],
    "carbonCopies": [],
    "certifiedDeliveries": [],
    "editors": [],
    "inPersonSigners": [],
    "intermediaries": [],
    "recipientCount": "1",
    "seals": [],
    "signers": [
      {
        "clientUserId": "recipient@email.com",
        "creationReason": "sender",
        "deliveryMethod": "email",
        "email": "recipient@email.com",
        "isBulkRecipient": "false",
        "name": "",
        "note": "",
        "recipientId": "1",
        "recipientIdGuid": "52abdeea-2bd6-4108-97b9-170ca27d573a",
        "requireIdLookup": "false",
        "roleName": "Leaseholder",
        "routingOrder": "1",
        "status": "created",
        "userId": "0570b3da-652e-4040-842e-65a0e6fc8133"
      }
    ]
    }
    
    1 回复  |  直到 6 年前
        1
  •  3
  •   Kim Brandl    6 年前

    这个 UNKNOWN_ENVELOPE_RECIPIENT 错误通常意味着为信封中的收件人指定的以下三个属性值之一与 获取收件人视图 请求:

    • Name
    • Email
    • ClientUserId

    在您的情况下(根据您发布的代码),我怀疑 未知的\u信封\u收件人 错误是由于您为收件人指定的信息 没有 包括的值 名称 属性--其中作为创建 RecipientViewRequest 对象 包括的值 UserName 属性(必须)。

    要修复此错误,我建议您在指定 TemplateRole 对象(其中“RECIPIENT\u NAME”是收件人的名字和姓氏)。

    tRole.Name = "RECIPIENT_NAME;
    

    然后为 用户名 的属性 RecipientViewRequest 对象:

    UserName = "RECIPIENT_NAME",
    

    (您指定为RECIPIENT\u NAME的值将是收件人在文档中签名的名称,因此您应该指定此人的名字/姓氏,而不是电子邮件地址。)


    更新

    关于后续 RECIPIENT_NOT_IN_SEQUENCE 您在评论中提到的错误,当您调用 获取收件人视图 对于收件人而言,在信封发送之前或在发送顺序中“轮到他们”接收信封之前。在你的情况下,我怀疑这是因为你没有设置 status 信封的 sent --在信封发送之前,收件人无法接收/访问该信封。要解决此错误,请在编写 EnvelopeDefinition 对象:

    envDef.Status = "sent";