且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Docusign:使用REST API和预填充标签通过模板创建信封

更新时间:2022-05-23 21:46:23

您的问题是您将JSON提交到获取收件人视图资源:

Your question says your submitting that JSON to the "Get Recipient View" resource:

https://demo.docusign.net/restapi/v2/accounts/ACCOUNT_ID/envelopes/ENVELOPE_ID/views/recipient)

...但是该JSON类似于您在创建信封请求中使用的JSON,而不是在获取收件人视图请求。因此,让我首先说明促进嵌入式/强制签名的过程(即在您的站点内显示收件人的信封)。这样做分为两个步骤:

...but that JSON looks like what you use in the "Create Envelope" request, not the "Get Recipient View" request. So, let me start by clarifying the process of facilitating Embedded/captive signing (i.e., presenting the recipient's envelope within your site). Doing so is a two-step process:

第1步:创建信封(请求中包含为每个收件人预填充字段的数据,

STEP 1: Create the envelope (request includes data to pre-populate fields for each recipient, if needed).

POST https://{server}/restapi/{apiVersion}/accounts/{accountId}/envelopes

请参阅从REST API指南的p27开始的从模板创建信封部分( http://www.docusign.com/sites/default/files/REST_API_Guide_v2.pdf )以获取有关请求和响应的详细信息。

See "Creating an Envelope From a Template" section that starts on p27 of the REST API guide (http://www.docusign.com/sites/default/files/REST_API_Guide_v2.pdf) for detailed info about request and response.

第2步:检索可用于启动收件人信封的URL(签名会话)。

STEP 2: Retrieve the URL that can be used to launch the recipient's envelope (signing session).

POST https://{server}/restapi/{apiVersion}/accounts/{accountId}/envelopes/{envelopeId}/views/recipient

{
"authenticationMethod":"Email",
"clientUserId":"CLIENT_USERID_SPECIFIED_IN_REQUEST",
"email":"RECIPIENT_EMAIL",
"returnUrl":"URL_TO_REDIRECT_TO_WHEN_SIGNING_COMPLETE",
"userName":"RECIPIENT_NAME"
}

响应将包含可用于启动收件人信封的URL:

The response will contain the URL that can be used to launch the Recipient's Envelope:

{
"url":"URL_THAT_WILL_LAUNCH_ENVELOPE"
}

请参阅后收件人视图部分从REST API指南的p160( http://www.docusign.com /sites/default/files/REST_API_Guide_v2.pdf )以获取有关请求和响应的更多详细信息。

See the "Post Recipient View" section that starts on p160 of the REST API guide (http://www.docusign.com/sites/default/files/REST_API_Guide_v2.pdf) for more detailed info about request and response.

现在,假设您正确执行了所有操作(步骤1和步骤2)-让我们得到b解决您要报告的问题:难以为收件人预填充字段。问题中包含有关从模板创建信封 JSON的一些注释:

Now, assuming you're doing all this correctly (step 1 and step 2) -- let's get back to the issue you're reporting: difficulty pre-populating fields for the recipient. A few comments about the "Create Envelope from Template" JSON that you included in your question:


  • 您不需要 accountId 在请求中。

  • 您无需在选项卡的请求中包含 documentId pageNumber

  • 如果您希望接收者在您的网站内进行嵌入/强制签名,则必须在请求中包括 clientUserId 。 $ b
  • You don't need accountId in request.
  • You don't need to include documentId and pageNumber in the request for the tab.
  • You DO need to include clientUserId for the recipient in the request, if you want the recipient to sign embedded/captive within your site.

因此,这是一个从模板创建/发送信封示例请求(上面的第1步),它预先填充了名为 FIELD_1在信封中出现的任何位置均带有值 VALUE_A:

So, here's a "Create/Send Envelope From Template" example request (step 1 above) that pre-populates the tab named "FIELD_1" with the value "VALUE_A" anywhere that it appears in the envelope:

POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes
{
    "status"        : "sent",
    "emailBlurb"    : "please sign",
    "emailSubject"  : "Please sign your document",
    "templateId"    : "TEMPLATE_ID",
    "templateRoles" : [{
      "name"         : "John Doe",
      "email"        : "JohnsEmail@outlook.com",
      "roleName"     : "Signer1Role",
      "clientUserId" : "123",
      "tabs"         :
         {"textTabs":[{
            "tabLabel":"\\*FIELD_1",
            "value":"VALUE_A"}
         ]}
   }]
}

然后,您将获取响应中返回的信封ID并调用获取收件人视图资源(上述第2步)来获取URL启动签名会话:

Then, you'd take the Envelope Id that's returned in the response and call the "Get Recipient View" resource (step 2 above) to get the URL to launch the signing session:

POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes/ENVELOPE_ID/views/recipient
{
     "authenticationMethod": "Email",
     "clientUserId": "123",
     "userName": "John Doe",
     "email": "JohnsEmail@outlook.com",
     "returnUrl": "http://www.google.com"
}

最后,最后一条评论(但重要的一条):如果您只是想在文档中注入收件人的全名,请在创建模板和DocuSign时使用 全名标签会自动在该标签出现的任何位置插入收件人的姓名,以代替该标签(而不是您使用文本标签,而必须通过API请求进行填充)。这是DocuSign UI标记视图中的全名标记:

Finally, one last comment (but an important one): if you're just wanting to inject the recipient's "full name" in the document -- use the "Full Name" tab when creating the Template and DocuSign will automatically inject the recipient's name in place of that tag, anywhere that it appears (instead of you using a Text Tab and having to populate it via the API request). Here's the Full Name tag in the DocuSign UI tagger view:

另一个创建信封示例(带有数据字段属性的屏幕截图):

如果我提交此请求:

POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes
{
  "emailSubject": "Please sign this",
  "emailBlurb": "Please sign...thanks!",
  "templateId": "TEMPLATE_ID",
  "envelopeIdStamping": "false",
  "templateRoles": [
   {
      "roleName": "Signer1",
      "name": "John Doe",
      "email": "JohnsEmail@outlook.com",
      "recipientId": "1",
      "tabs":{
            "textTabs":[
               {
                  "tabLabel":"\\*address",
                  "value":"123 Main Street"
               },
            ],
         }
    }
  ],
  "status": "sent"
}

数据字段属性(通过DocuSign UI编辑模板时)如下所示:

And the Data Field properties (when Editing the Template via the DocuSign UI) look like this:

然后,结果是带有Label = address 的字段当签名者查看其信封时,分配给收件人角色 Signer1 的>将预先填充值 123 Main Street。如果这不适合您,我建议您:

Then the result is that field(s) with Label = address that are assigned to Recipient Role Signer1 will be prepopulated with the value "123 Main Street" when the signer views their envelope. If this isn't working for you, I suggest that you:


  • 验证在其中的 roleName 的值API请求完全与我在上一个屏幕截图中突出显示的收件人值匹配(在我的示例中为 Signer1)。

  • 验证 tabLabel 完全与我在上一个屏幕截图中突出显示的Label值(在我的示例中为地址。)

  • Verify that the value of roleName in the API request exactly matches the Recipient value I've highlighted in the prior screenshot (in my example, "Signer1").
  • Verify that the value of tabLabel in the API request exactly matches the Label value I've highlighted in the prior screenshot (in my example, "address).

注意 :值是 区分大小写 ,因此确保您请求中的值与数据字段标记属性中的值 精确 匹配(包括大写/小写)。

Note: Values are case-sensitive, so be sure values in your request are an exact match (including upper-case/lower-case) with the values in the Data Field Tag Properties.