docusign ::如何取消“正在进行中”的信封?

时间:2013-10-10 05:21:07

标签: docusignapi

请帮忙。

我一直试图用三个签名中的一个签名来取消“正在进行中”的信封,但是我收到了这个错误信息。 我按照http://www.docusign.com/p/RESTAPIGuide/Content/REST%20API%20References/Void%20Envelope.htm的说明进行操作。

还看了上一个问题,但这根本没有帮助我。

错误 该请求至少包含一个无效参数。信封定义中“状态”的值无效。只允许“已发送”或“已创建”(默认)。

网址:https://demo.docusign.net/restapi/v2/accounts/35 * / envelopes / f466ad3f-d391 - * - - * * ** *

参数:{“状态”:“无效”,“无效的理由”:“因迟到请求而无效。”} INVALID_REQUEST_PARAMETER

提前致谢。

1 个答案:

答案 0 :(得分:2)

您确定要执行PUT请求而不是POST吗?

刚刚测试过,并且可以使用与您列出的相同的请求体,在没有任何问题的情况下使3个信封无效。不确定你正在使用什么语言,但这是一个完整的PHP程序,它创建并发送一个信封,以便在进程中,然后它立即使它无效。

要运行此程序:

  1. 将代码保存为本地文件,例如“test.php”。
  2. 在顶部输入凭据(电子邮件,密码,集成键,名称)
  3. 将测试PDF文档复制到同一目录,重命名为“document.pdf”
  4. 在命令行上运行php test.php
  5. 这是代码,不要忘记替换信用卡......

    <?php
    
        // Input your info here:
        $integratorKey = '***';
        $email = '***';
        $password = '***';
        $name = '***';
    
        // 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 with one recipient, one tab, and one document and send
        /////////////////////////////////////////////////////////////////////////////////////////////////
        $data = array (
                "emailBlurb" => "Custom PHP script",
                "emailSubject" => "Radio Buttons Testing",
                "status" => "sent",
                "documents" => array(array( "documentId" => "1", "name" => "document.pdf")),
                "recipients" => array( "signers" => array(
                        array( "email" => $email,
                                "name" => "$name",
                                "recipientId" => "1",
                                "clientUserId" => "1001",
                                "tabs" => array(
                                        "signHereTabs" => array(
                                            array(
                                                "xPosition" => "100",
                                                "yPosition" => "200",
                                                "documentId" => "1",
                                                "pageNumber" => "1"
                                             )
                                        ),
                                        "radioGroupTabs" => array(
                                            array (
                                                "documentId" => "1",                                        
                                                "groupName" => "RadioGroup1",
                                                "radios" => array (
                                                    array(
                                                        "pageNumber" => "1",
                                                        "selected" => "false",
                                                        //"value" => "X",
                                                        "xPosition" => "300",
                                                        "yPosition" => "75"
                                                        ),
                                                    array(
                                                        "pageNumber" => "1",
                                                        "selected" => "false",
                                                        "xPosition" => "350",
                                                        "yPosition" => "75"
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                            )
                    ) 
            );
    
        $data_string = json_encode($data);  
    
        $file_contents = file_get_contents("document.pdf");
    
        $requestBody = "\r\n"
        ."\r\n"
        ."--myboundary\r\n"
        ."Content-Type: application/json\r\n"
        ."Content-Disposition: form-data\r\n"
        ."\r\n"
        ."$data_string\r\n"
        ."--myboundary\r\n"
        ."Content-Type:application/pdf\r\n"
        ."Content-Disposition: file; filename=\”document.pdf\"; documentid=1 \r\n"
        ."\r\n"
        ."$file_contents\r\n"
        ."--myboundary--\r\n"
        ."\r\n";
    
        // *** append "/envelopes" to baseUrl and as signature request endpoint
        $curl = curl_init($baseUrl . "/envelopes" );
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody);                                                                  
        curl_setopt($curl, CURLOPT_HTTPHEADER, array(                                                                          
            'Content-Type: multipart/form-data;boundary=myboundary',
            'Content-Length: ' . strlen($requestBody),
            "X-DocuSign-Authentication: $header" )                                                                       
        );
    
        $json_response = curl_exec($curl);
        $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        if ( $status != 201 ) {
            echo "error calling webservice, status is:" . $status . "\nerror text is --> ";
            print_r($json_response); echo "\n";
            exit(-1);
        }
    
        $response = json_decode($json_response, true);
        $envelopeId = $response["envelopeId"];
    
        curl_close($curl);
    
        //--- display results
        echo "Document is sent! Envelope ID = " . $envelopeId . "\n"; 
    
        /////////////////////////////////////////////////////////////////////////////////////////////////
        // STEP 3 - Get the Embedded Singing View 
        /////////////////////////////////////////////////////////////////////////////////////////////////   
        $data = array("status" => "voided", "voidedReason" => "test");
        $data_string = json_encode($data);    
    
        echo "Attempting to void envelope $envelopeId\nVoid request body is:  $data_string\n";
    
        $curl = curl_init($baseUrl . "/envelopes/$envelopeId" );
        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);
    
        echo "Done.\n";
        curl_close($curl);
    ?>