Reputation: 173
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?
Upvotes: 6
Views: 2382
Reputation: 128
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);
Upvotes: 0
Reputation: 179
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/
Upvotes: 8
Reputation: 173
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;
Upvotes: 11
Reputation: 9356
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?
Upvotes: -1