簡體   English   中英

如何使用REST API在DocuSign中為收件人設置clientUserId?

[英]How to set clientUserId for a Recipient in DocuSign using the REST API?

我正在嘗試創建一個RecipientView,以通過應用程序發送到創建的信封的收件人。 使用DocuSign的較新API,這需要一個userName ,該userName由創建需要簽名的文檔的人輸入,一封email (僅是收件人的電子郵件),以及一個clientUserId (由發件人生成的字符串值來驗證收件人的身份)嵌入式簽名者,以便可以生成RecipientView來主持簽名儀式。

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是造成此問題的原因,因為文檔說我需要設置clientUserId ,而不僅僅是在進行調用時創建一個值。 如何通過REST API設置收件人的clientUserId

更新:在這種情況下,我將不是創建和發送信封的人。 這將由我通過我的應用程序擁有的客戶端完成,其中大多數將很可能使用Web界面而不是API來執行此操作。 我確實有權訪問有關每個客戶端的Admin帳戶的所有信息,包括集成商密鑰,訪問令牌,信封ID,帳戶ID等。

對於嵌入式簽名(又稱為收件人視圖),您需要撥打兩個電話。 好吧,實際上有3個調用,包括初始的Login API,但這聽起來像您已經完成了工作,所以我將重點介紹其他兩個。

步驟#1 :創建帶有嵌入式收件人的信封。 當添加收件人確保您設置自己的nameemailrecipientIdclientUserId

步驟2 :為簽名者請求信封的收件人視圖。 要做到這一點,你需要調用EnvelopeViews:createRecipient API,你必須引用完全相同的設置您在步驟1中設置收件人值(即nameemailrecipientIdclientUserId

查看App API食譜中的“ 簽名 ”以獲取完整的代碼示例。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM