Voiding an envelope using the new DocuSign C# Client
Asked Answered
E

4

6

I am trying to void an existing envelope using the updated version of the DocuSign C# Client (DocuSign.eSign).

The envelope is in the Sent status and has not been completed or voided already.

Currently I have following code:

EnvelopesApi envelopesApi = new EnvelopesApi();

Envelope envelope = envelopesApi.GetEnvelope(accountId, envelopeId);           
envelope.Status = "voided";
envelope.VoidedReason = "This envelope was voided by " + currentUserName;

// create the recipient view (aka signing URL)
var updateSummary = envelopesApi.Update(accountId, envelopeId, envelope);

return updateSummary;

When this code is called, it fails with an ApiException and the following ErrorContent:

{
  "errorCode": "INVALID_REQUEST_PARAMETER",
  "message": "The request contained at least one invalid parameter. Value for 'purgeState' must be 'documents_queued' or 'documents_and_metadata_queued'."
}

The message is "The request contained at least one invalid parameter. Value for 'purgeState' must be 'documents_queued' or 'documents_and_metadata_queued'", but according to the docs, I shouldn't need to supply those parameter if the status is "voided" and I have a voided reason.

Is there a way to void an envelope using the DocuSign C# Client?

Elastic answered 1/7, 2016 at 16:51 Comment(0)
E
10

The issue appears to be that the envelope.PurgeState was set to "unpurged" when the envelope was loaded and that was passed to the API call. So even though I didn't explicitly set a PurgeState, it thought I was trying to perform the purge action with invalid parameters.

I was able to solve this by explicitly unsetting the envelope.PurgeState:

envelope.Status = "voided";
envelope.VoidedReason = "This envelope was voided by " + currentUserName;
envelope.PurgeState = null;
Elastic answered 7/7, 2016 at 21:48 Comment(0)
S
8

I know this is an old question but I want to add that you don't need to call the API to get the original envelope object, just set the properties you need and send the Update call.

    public EnvelopeUpdateSummary VoidRequest(string envelopeId, string message)
    {
        var envelope = new Envelope()
        {
            Status = "voided",
            VoidedReason = message
        };

        var updateSummary = EnvelopesApi.Update(AccountId, envelopeId, envelope);
        return updateSummary;
    }

You can check the documentation: https://docs.docusign.com/esign/restapi/Envelopes/Envelopes/update/

Septilateral answered 9/5, 2018 at 17:11 Comment(3)
Down vote: When I run this code, I get: Error calling Update: PARTNER_AUTHENTICATION_FAILED. The specified integrator key was not found or is disabled. An integrator key was not specified.Tradespeople
@pianocomposer, this answer is from 3 years ago. For sure your environment now is not the same of mine back at 2018. Hope you find a solution that help you out. Best RegardsSeptilateral
@Tradespeople that will be related to your Oauth/JWT configuration - completely unrelated to this answerPictorial
T
0

You must set the access token. I got that code straight from DocuSign support. Otherwise you get an integration key missing error. The PurgeState line is not necessary, but it solves a problem mentioned above. None of the code above worked for me until I added the default configuration header.

                        var apiClient = new ApiClient(config.host);
                    // sets the integrator key
                    apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + config.tokenInfo.access_token);
                    EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);

                    var env = new Envelope();
                    env.Status = "voided";
                    env.VoidedReason = "Entity requested void of PDF";
                    env.PurgeState = null;

                    envelopesApi.Update(config.targetAccountId, envelope.EnvelopeId, env);
Tradespeople answered 15/9, 2021 at 17:13 Comment(0)
B
-1

You cannot void envelopes that are in a Terminal state (i.e Completed or Voided), can you confirm the status of the envelope you're trying to void?

Breaststroke answered 1/7, 2016 at 19:12 Comment(2)
This is worth further investigation. The error message provided looks like an attempt to purge (delete) envelope documents/metadata as opposed to voiding (cancel) the transaction. If you try to void an envelope which is already voided the error message would be: "errorCode": "ENVELOPE_CANNOT_VOID_INVALID_STATE", "message": "Only envelopes in the 'Sent' or 'Delivered' states may be voided."Ventral
The Status of the envelope I was trying to void was In Process / Sent. I will update the question to clarifyElastic

© 2022 - 2024 — McMap. All rights reserved.