1

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.

Ergin
  • 9,254
  • 1
  • 19
  • 28

1 Answers1

3

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);
?>
Ergin
  • 9,254
  • 1
  • 19
  • 28
  • Thanks for answer, but now I am getting this msg The request body is missing or improperly formatted. URL: https://demo.docusign.net/restapi/v2/accounts/353***/envelopes/3f8fbe05-63f9-418a-****** PARAMS: {"status":"voided","voidedReason":"test"} INVALID_REQUEST_BODY – user2855591 Oct 10 '13 at 18:28
  • What language are you using, and how are you forming your JSON? Just hard-coding into a string? – Ergin Oct 10 '13 at 20:01
  • There must be something else wrong with your request, I just tested three times and was able to create a new envelope, send it, and void the envelope with no problems each time. I'll attach a full working PHP program that does this. YOu need to show your relevant code... – Ergin Oct 10 '13 at 20:11
  • 1
    I was having the exact same problem. I was trying to submit a void over the API and was getting, "INVALID_REQUEST_PARAMETER; The request contained at least one invalid parameter. Invalid value for 'status' in envelope definition. Only 'sent' or 'created' (default) are allowed." I reviewed my cURL request and added the following line: curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT'); After this, voids worked fine. – Tanoro Apr 15 '15 at 17:07
  • Thanks for posting, I assume that's the same issue the person who posted this question was running into and they just never accepted as an answer... – Ergin Apr 17 '15 at 17:46