我有一个演示开发DocuSign帐户,因为我正在尝试使用API,以便可以将收件人定向到发件人(在这种情况下的发件人是我)签名的文档。每当我POST
API 以获取我发送给自己的文档的收件人视图时,它都会成功,并且 url 会正确返回。但是,当我向除我自己以外的任何人请求收件人的 URL 时,我会收到400 Bad Call
错误。我正在 PHP 中实现这一点,但我也在 REST API 资源管理器上尝试过这个以获得相同的结果。
这是向自己发送文档时有效的代码。 $account_id
、 $envelope_id
、 $recipient
是通过数据库找到的,并且返回正确的值,因此假设它们在您看到它们的地方是正确的:
$url = "https://demo.docusign.net/restapi/v2/accounts/".$account_id."/envelopes/$envelope_id/views/recipient";
$body = array("returnUrl" => "https://www.docusign.com/devcenter",
"authenticationMethod" => "None",
"email" => "$recipient",
"userName" => "$recipient");
$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($connection));
}
这将返回以下 JSON:
{
"url": "www.urlexample.com"
}
由于默认情况下收件人未获得授权,因此在请求除我自己以外的收件人时,我必须更改$body
,不仅包括"authenticationMethod"
和"returnUrl"
,还包括"userId"
和"recipientId"
,它们应该匹配和"clientUserId"
(这将是我的开发人员 userId),以便 DocuSign 知道此请求是在授权下发出的。但是,我似乎无法做到这一点。
这是我为$body
尝试的:
$url = "https://demo.docusign.net/restapi/v2/accounts/".$account_id."/envelopes/$envelope_id/views/recipient";
$body = array("authenticationMethod" => "email",
"clientUserId" => "314c7a19-49ff-4405-a958-42344273060c",
"returnUrl" => "https://www.docusign.com/devcenter",
"recipientId" => "a3f182e7-65b6-4bc1-b603-cc8ed23fed0d"
"userId" => "a3f182e7-65b6-4bc1-b603-cc8ed23fed0d"
);
此请求(替换为前面的代码)返回具有以下 JSON 的400
错误:
{
"errorCode": "UNKNOWN_ENVELOPE_RECIPIENT",
"message": "The recipient you have identified is not a valid recipient of the specified envelope."
}
然而,这没有任何意义,因为"recipientId"
和"userId"
都匹配,而且$envelope_id
也绝对正确(我三重检查)。
底线:如果收件人未获得授权,如何为收件人视图生成 URL?
假设信封已"发送"且未处于"已创建"状态。尝试在创建的信封上传递与收件人匹配的用户名和电子邮件,对应于姓名和电子邮件。 如果信封的原始创建中存在客户端用户 ID,也必须匹配。
如果不是这样 - 请发布您如何创建信封。执行此操作的最佳方法是捕获原始 API 请求日志并发布 JSON: https://support.docusign.com/articles/API-Request-Logging
若要为给定信封中的收件人生成签名令牌,需要满足以下条件之一:
- 您需要成为信封的发件人。
- 您需要是发送帐户的管理员。
您能否确认在您的案例中以下情况之一属实?