我正嘗試創建一個RecipientView,通過應用程序發送給創建的信封的收件人。使用DocuSign的較新的API,這需要userName
,由創建需要簽名的文檔的人員輸入,email
(僅爲收件人的電子郵件)和clientUserId
(發件人生成的字符串值,用於驗證收件人爲一個嵌入簽名者,以便可以生成一個RecipientView來主持簽名儀式。如何使用REST API爲DocuSign中的收件人設置clientUserId?
DocuSign文檔引用,我需要設置clientUserId
,但它沒有提及如何要做到這一點,而不是通過API創建信封時。但是,在這種情況下,DocuSign Admin客戶端將通過實際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此請求後,返回JSON應該是:
{
"url": "example.example.com"
}
然而,回報我得到了不屬於的DocuSign帳戶的管理收件人是:
{
"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
?
更新:在這種情況下,我不會是創建和發送信封的人。這將由我通過我的應用程序完成的客戶端完成,其中絕大多數客戶端很可能會使用Web界面來執行此操作,而不是API。我確實可以訪問有關每個客戶的管理員帳戶的所有信息,包括集成商密鑰,訪問令牌,信封ID,帳戶ID等。
我正在犯的錯誤是沒有設置clientUserId。由於創建信封時我無法控制該字段,因此必須先設置clientUserId,然後再調用嵌入的簽名者url。 – Jodo1992