如何使用 REST API 在 DocuSign 中为收件人设置 clientUserId?
How to set clientUserId for a Recipient in DocuSign using the REST API?
我正在尝试创建一个 RecipientView 以通过应用程序将所创建的信封发送给收件人。使用 DocuSign 的更新 API,这需要一个 userName
,它由创建需要签名的文档的人输入,一个 email
,它只是收件人的电子邮件,以及一个 clientUserId
这是发件人生成的字符串值,用于将收件人验证为嵌入式签名者,以便可以生成 RecipientView 来主持签名仪式。
我需要设置 clientUserId
的 DocuSign 文档参考,但它没有提到 如何 除了通过 API。但是,在这种情况下,信封将由 DocuSign 管理员客户端通过实际 Web 界面上的模板创建,并且 而不是 通过 API。
我生成 RecipientView 的代码都在这里设置:
$url = "https://demo.docusign.net/restapi/v2/accounts/$account_id/envelopes/$envelope_id/views/recipient";
$body = array("returnUrl" => "http://www.docusign.com/devcenter",
"authenticationMethod" => "None",
"email" => "$email",
"userName" => "$name",
"recipientId" => "$recipientId",
"clientUserId" => "1000"
);
$body_string = json_encode($body);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Content-Length: '.strlen($body_string),
"Authorization: Bearer $access_token"
));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body_string);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status != 201){
die('Could not connect to end point: '.mysqli_error($conn));
}
$response = json_decode($json_response, true);
$url = $response["url"];
此代码在嵌入式签名者是管理员帐户时有效,但在将信封发送给实际收件人时无效。此请求后来自 DocuSign 的 return JSON 应为:
{
"url": "example.example.com"
}
但是,我为非 DocuSign 帐户管理员的收件人收到的 return 是:
{
"errorCode": "UNKNOWN_ENVELOPE_RECIPIENT",
"message": "The recipient you have identified is not a valid recipient of the
specified envelope."
}
我相信不设置 clientUserId
是这背后的原因,因为 documentation 说我需要设置 clientUserId
而不仅仅是在调用时创建一个值。如何通过 REST API 设置收件人的 clientUserId
?
更新:在这种情况下,我不会是创建和发送信封的人。这将由我通过我的应用程序拥有的客户完成,他们中的大多数人很可能会使用网络界面来完成这项工作,而不是 API。我确实有权访问有关每个客户的管理员帐户的所有信息,包括集成商密钥、访问令牌、信封 ID、帐户 ID 等。
对于嵌入式签名(又名收件人视图),您需要进行两次调用。好吧,实际上有 3 个调用,包括初始登录 API,但听起来你已经成功了,所以我将专注于其他两个。
步骤 #1:创建一个带有嵌入式收件人的信封。添加收件人时,请确保设置他们的 name
、email
、recipientId
和 clientUserId
。
步骤 #2:为您的签名者请求信封的收件人视图。为此,您需要调用 EnvelopeViews: createRecipient API 并且您必须为您在步骤 1 中设置的收件人引用相同的一组值(即 name
、email
、recipientId
, 和 clientUserId
)
查看 Signing from Within your App API 秘诀以获得完整的代码示例。
我正在尝试创建一个 RecipientView 以通过应用程序将所创建的信封发送给收件人。使用 DocuSign 的更新 API,这需要一个 userName
,它由创建需要签名的文档的人输入,一个 email
,它只是收件人的电子邮件,以及一个 clientUserId
这是发件人生成的字符串值,用于将收件人验证为嵌入式签名者,以便可以生成 RecipientView 来主持签名仪式。
我需要设置 clientUserId
的 DocuSign 文档参考,但它没有提到 如何 除了通过 API。但是,在这种情况下,信封将由 DocuSign 管理员客户端通过实际 Web 界面上的模板创建,并且 而不是 通过 API。
我生成 RecipientView 的代码都在这里设置:
$url = "https://demo.docusign.net/restapi/v2/accounts/$account_id/envelopes/$envelope_id/views/recipient";
$body = array("returnUrl" => "http://www.docusign.com/devcenter",
"authenticationMethod" => "None",
"email" => "$email",
"userName" => "$name",
"recipientId" => "$recipientId",
"clientUserId" => "1000"
);
$body_string = json_encode($body);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Accept: application/json',
'Content-Type: application/json',
'Content-Length: '.strlen($body_string),
"Authorization: Bearer $access_token"
));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body_string);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status != 201){
die('Could not connect to end point: '.mysqli_error($conn));
}
$response = json_decode($json_response, true);
$url = $response["url"];
此代码在嵌入式签名者是管理员帐户时有效,但在将信封发送给实际收件人时无效。此请求后来自 DocuSign 的 return JSON 应为:
{
"url": "example.example.com"
}
但是,我为非 DocuSign 帐户管理员的收件人收到的 return 是:
{
"errorCode": "UNKNOWN_ENVELOPE_RECIPIENT",
"message": "The recipient you have identified is not a valid recipient of the
specified envelope."
}
我相信不设置 clientUserId
是这背后的原因,因为 documentation 说我需要设置 clientUserId
而不仅仅是在调用时创建一个值。如何通过 REST API 设置收件人的 clientUserId
?
更新:在这种情况下,我不会是创建和发送信封的人。这将由我通过我的应用程序拥有的客户完成,他们中的大多数人很可能会使用网络界面来完成这项工作,而不是 API。我确实有权访问有关每个客户的管理员帐户的所有信息,包括集成商密钥、访问令牌、信封 ID、帐户 ID 等。
对于嵌入式签名(又名收件人视图),您需要进行两次调用。好吧,实际上有 3 个调用,包括初始登录 API,但听起来你已经成功了,所以我将专注于其他两个。
步骤 #1:创建一个带有嵌入式收件人的信封。添加收件人时,请确保设置他们的 name
、email
、recipientId
和 clientUserId
。
步骤 #2:为您的签名者请求信封的收件人视图。为此,您需要调用 EnvelopeViews: createRecipient API 并且您必须为您在步骤 1 中设置的收件人引用相同的一组值(即 name
、email
、recipientId
, 和 clientUserId
)
查看 Signing from Within your App API 秘诀以获得完整的代码示例。