如何在DocuSign中加载带有信封ID的嵌入式签名请求?

时间:2015-07-14 03:57:40

标签: docusignapi

我有用于模拟帐户设置的API。到目前为止,我已经能够创建我的演示联系人收到的签名请求。我想使用API​​的嵌入式签名部分来加载信封的收件人视图,但我得到这两个响应中的任何一个(如下所示)。

我有信封ID,我知道(唯一)收件人的电子邮件和用户名,我可以在Sandbox UI中看到此信息。

我的请求具有用于创建信封的相同JSON授权密钥字符串。

以下是我发送的两个示例有效负载(X代替敏感信息):

请求:

POST /restapi/v2/accounts/110XXXX/envelopes/7dee22f3-90e6-44b0-be6b-XXXXXXX/views/recipient HTTP/1.1
X-DocuSign-Authentication: {"Username":"a312a32d-df78-423e-b916-XXXXXXXXX","Password":"XXXXXX","IntegratorKey":"CONN-18a3c56f-f776-40db-8e33-XXXXXXXXX"}
Accept: application/json
Content-Type: application/json
Cookie: BIGipDocuSign=!aI+3n7V3fB0xBxEb7loYjpEeRwCxTKC4na93ET3RH8aETpEeGTqTaKaY1y6ui+nhmrX85Xa90CfKgfk=
Host: demo.docusign.net
Connection: close
Content-Length: 186

{
  "authenticationMethod": "email",
  "email": "adam@example.com",
  "returnUrl": "http://lvh.me:3000",
  "userName": "John Smith",
  "clientUserId":"21"
}

响应:

HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Content-Length: 152
Content-Type: application/json; charset=utf-8
X-RateLimit-Reset: 1436846400
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 998
Date: Tue, 14 Jul 2015 03:43:01 GMT
Connection: close
Set-Cookie: BIGipDocuSign=!aI+3n7V3fB0xBxEb7loYjpEeRwCxTKC4na93ET3RH8aETpEeGTqTaKaY1y6ui+nhmrX85Xa90CfKgfk=;secure; path=/
Strict-Transport-Security: max-age=31536000; includeSubDomains

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

-----或-----

请求:

POST /restapi/v2/accounts/110XXXX/envelopes/7dee22f3-90e6-44b0-be6b-XXXXXXX/views/recipient HTTP/1.1
X-DocuSign-Authentication: {"Username":"a312a32d-df78-423e-b916-XXXXXXXXX","Password":"XXXXXX","IntegratorKey":"CONN-18a3c56f-f776-40db-8e33-XXXXXXXXX"}
Accept: application/json
Content-Type: application/json
Cookie: BIGipDocuSign=!aI+3n7V3fB0xBxEb7loYjpEeRwCxTKC4na93ET3RH8aETpEeGTqTaKaY1y6ui+nhmrX85Xa90CfKgfk=
Host: demo.docusign.net
Connection: close
Content-Length: 158

{ 
  "authenticationMethod": "email",
  "email": "adam@example.com",
  "returnUrl": "http://lvh.me:3000",
  "userName": "John Smith"
}

响应:

HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Content-Length: 140
Content-Type: application/json; charset=utf-8
X-RateLimit-Reset: 1436846400
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 997
Date: Tue, 14 Jul 2015 03:53:06 GMT
Connection: close
Set-Cookie: BIGipDocuSign=!J6eG9xlLFCmIIZgb7loYjpEeRwCxTPgRydEJMtaaTaMNaqpZpXKRTbRGctfwEWaI3Ptas3QeaupEj2o=;secure; path=/
Strict-Transport-Security: max-age=31536000; includeSubDomains

{
  "errorCode": "ACCOUNT_NOT_AUTHORIZED_FOR_ENVELOPE",
  "message": "This account is not authorized to access the requested envelope."
}

1 个答案:

答案 0 :(得分:1)

我建议您遵循Quickstart以及DocuSign开发人员中心的文档。快速入门中有一个部分介绍了嵌入式签名,还有一个专用于Embedding functionality的功能页面,其中包含您需要的所有信息。

步骤1:创建包含嵌入收件人的信封

要将收件人指定为嵌入式(意味着他们不会通过电子邮件而是通过您的应用程序启动请求),您只需将收件人的clientUserId属性设置为非空值 - 您的第一个示例看起来很好用它设为21。典型的信封定义如下:

{
    "documents": [{
        "documentBase64": "<Base64BytesHere>",
        "documentId": "1",
        "name": "Test"
    }],
    "emailSubject": "Testing",
    "recipients": {
        "signers": [{
            "name": "John Doe",         
            "email": "john@email.com",
            "clientUserId": "21",               
            "recipientId": "1"
        }]
    },
    "status": "sent"
}

由于为此收件人设置了clientUserId,因此在发送请求时,他们不会收到电子邮件通知(尽管这是一个帐户设置,您可以修改为仍然可以发送电子邮件)。

API方法:Envelopes: create

第2步:请求收件人视图(也称嵌入式签名)

信封与嵌入式收件人一起发送后,您只需生成签名网址即可。要生成签名URL,您必须提供将收件人添加到信封时提供的完全相同的收件人参数。换句话说,您必须提供完全相同的userNameemailclientUserId请注意,此API中的名称字段名为userName,而不是创建信封API 中使用的name

典型的请求如下:

{
    "authenticationMethod": "email",
    "userName": "John Doe",
    "email": "john@email.com",              
    "clientUserId": "21",
    "returnUrl": "http://www.google.com"
}

API方法:EnvelopeViews: createRecipient