DocuSign PUT resend_envelope=true

DocuSign PUT resend_envelope=true

我正在开发与 DocuSign REST 接口的东西 API。发送和作废信封工作正常,但我在尝试重新发送信封时遇到问题。

我收到对我的 PUT 调用(如下)的错误请求状态响应,旨在 1) 更正错误的电子邮件地址或 2) 强制重新发送,因为客户端输入了错误的访问代码并将信封放入身份验证失败状态。

这是 url(在我的实时应用程序中适当替换了 accountId 和 envelopdId)我在创建请求时使用 PUT 方法:

https://demo.docusign.net/restapi/v2/accounts/{accountId}/envelopes/{envelopeId}/recipients?resend_envelope=true

创建请求后(出于测试目的)我立即写出了请求 headers,它看起来像下面这样:

X-DocuSign-Authentication: <DocuSignCredentials><Username>omitted</Username><Password>omitted</Password><IntegratorKey>omitted</IntegratorKey></DocuSignCredentials>
Accept: application/xml
Content-Type: application/xml
Host: demo.docusign.net

请求 body 如下所示。请注意,根据 DocuSign 支持人员的建议,我对此有多种变体,有和没有 xmlns 属性,有和没有签名者节点。

<signers>
  <signer>
    <name>FName LName</name>
    <email>emailaddr@fake.com</email>
    <recipientId>1</recipientId>
  </signer>
</signers>

我收到的错误请求响应如下,响应中的实际 envelopeId 与我的重新发送请求匹配。

<envelopeSummary xmlns="http://www.docusign.com/restapi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><envelopeId>omitted</envelopeId><status>bad request</status><statusDateTime>6/5/2015 2:41:04 PM</statusDateTime></envelopeSummary>

DocuSign 支持已审核以上所有内容,但他们无法就重新发送请求失败的原因提供任何意见。支持人员表示,他们看到的不是 PUT 调用,而是在 envelopeId 之前结束的 POST。没有意义。

对于可能出现的问题的任何反馈,我将不胜感激。谢谢

***** 我将我的请求 body 更改为 json 并成功更新了信封电子邮件地址。但是,这并没有触发重新发送。

*****出于好奇,我重新发送了信封,很高兴它被重新发送了。奇怪的是,第一个 PUT 对更正进行了操作(将错误的电子邮件地址更改为更正后的电子邮件地址),但没有导致重新发送信封。第二个 PUT 对重新发送起作用(没有任何改变)。

这对我来说是按预期工作的,这是一个完整的工作解决方案,它从模板创建一个新的包络,发送它,然后它对该正在运行的包络执行更正。我得到返回的成功状态,并在控制台中看到更新的收件人信息。

<?php

    // Input your info here:
    $email = "***";         // your account email (also where this signature request will be sent)
    $password = "***";      // your account password
    $integratorKey = "***";     // your account integrator key, found on (Preferences -> API page)
    $recipientName = "***";     // provide a recipient (signer) name
    $templateId = "***";        // provide a valid templateId of a template in your account
    $templateRoleName = "***";  // use same role name that exists on the template in the console

    // construct the authentication header:
    $header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";

    /////////////////////////////////////////////////////////////////////////////////////////////////
    // STEP 1 - Login (to retrieve baseUrl and accountId)
    /////////////////////////////////////////////////////////////////////////////////////////////////
    $url = "https://demo.docusign.net/restapi/v2/login_information";
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));

    $json_response = curl_exec($curl);
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    if ( $status != 200 ) {
        echo "error calling webservice, status is:" . $status;
        exit(-1);
    }

    $response = json_decode($json_response, true);
    $accountId = $response["loginAccounts"][0]["accountId"];
    $baseUrl = $response["loginAccounts"][0]["baseUrl"];
    curl_close($curl);

    // --- display results
    echo "\naccountId = " . $accountId . "\nbaseUrl = " . $baseUrl . "\n";

    /////////////////////////////////////////////////////////////////////////////////////////////////
    // STEP 2 - Create an envelope from a template and send
    /////////////////////////////////////////////////////////////////////////////////////////////////
    $data = array("accountId" => $accountId, 
        "emailSubject" => "DocuSign API - Signature Request from Template",
        "templateId" => $templateId, 
        "templateRoles" => array( 
                array( "recipientId" => "1234", "email" => $email, "name" => $recipientName, "roleName" => $templateRoleName )),
        "status" => "sent");

    $data_string = json_encode($data);  
    $curl = curl_init($baseUrl . "/envelopes" );
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);                                                                  
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(                                                                          
        'Content-Type: application/json',                                                                                
        'Content-Length: ' . strlen($data_string),
        "X-DocuSign-Authentication: $header" )                                                                       
    );

    $json_response = curl_exec($curl);
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ( $status != 201 ) {
        echo "ERROR- Status returned = " . $status . "\nerror text is --> ";
        print_r($json_response); echo "\n";
        exit(-1);
    }

    $response = json_decode($json_response, true);
    $envelopeId = $response["envelopeId"];

    // --- display results
    echo "Document is sent! Envelope ID = " . $envelopeId . "\n\n"; 

    /////////////////////////////////////////////////////////////////////////////////////////////////
    // STEP 3 - Perform correction and resend envelope
    /////////////////////////////////////////////////////////////////////////////////////////////////

    echo "Performing envelope correction...\n";

    $data_string = 
        "{
          \"signers\" :
          [
            {
              \"email\": \"new_email_address\",
              \"name\": \"new_recipient_name\",
              \"recipientId\": \"1234\"
            }
          ]
        }";

    $curl = curl_init($baseUrl . "/envelopes/$envelopeId/recipients" . "?resend_envelope=true" );
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string);                                                                  
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(                                                                          
        'Content-Type: application/json',                                                                                
        'Content-Length: ' . strlen($data_string),
        "X-DocuSign-Authentication: $header" )                                                                       
    );

    $json_response = curl_exec($curl);
    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ( $status != 200 ) {
        echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
        print_r($json_response); echo "\n";
        exit(-1);
    }

    $response = json_decode($json_response, true);

    // --- display results
    echo "Correction result = " . "\n\n" . $json_response. "\n\n"; 
?>