1
votes

Please help.

I have been trying to void a "in-progress" envelope with one signature out of three signatures, but I receive this error msg. I follow the instruction from : http://www.docusign.com/p/RESTAPIGuide/Content/REST%20API%20References/Void%20Envelope.htm.

Also looked at the previous question asked, but that didn't help me at all.

Error The request contained at least one invalid parameter. Invalid value for 'status' in envelope definition. Only 'sent' or 'created' (default) are allowed.

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

PARAMS: {"status":"voided","voidedReason":"Voided due to late change request."} INVALID_REQUEST_PARAMETER

Thanks in advance.

1

1 Answers

3
votes

Are you sure you're doing a PUT request and not a POST?

Just tested and was able to void 3 envelopes just fine with no problems, using the same request body as you've listed. Not sure what language you're using, but here's a full working PHP program that creates and sends an envelope so that's in-process, then it immediately voids it.

To run this program:

  1. Save code as local file, say "test.php".
  2. Enter credentials at top (email, pwd, integrator key, name)
  3. Copy a test PDF document to same directory, rename to "document.pdf"
  4. run php test.php on command line

Here's the code, don't forget to replace creds...

<?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);
?>