DeleteEnvelope - C#

Copy
// DocumentNOW V2 DeleteEnvelope example
// note, you can pass eith documentID or envelopeID values in

// force TLS 1.2 if .net < 4.6
ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
    
Guid accountContextID = new Guid(<fromYourAccount>);
Guid envelopeId = new Guid(<fromCreateEnvelope>);
Guid authToken = new Guid(<fromCreateEnvelope>);

// assuming we set the namespace on the service proxy to DocNow ...
DocNow.EnvelopeServiceClient client = new DocNow.EnvelopeServiceClient("BasicHttpBinding_IEnvelopeService1");
DocNow.DeleteEnvelopeRequest request = new DocNow.DeleteEnvelopeRequest();

request.ContextIdentifier = accountContextID;
request.EnvelopeId = envelopeId
request.EnvelopeAuthToken = authToken;
// .net proxy code mechanism for dealing with optional parameters
request.EnvelopeAuthTokenSpecified = true;
request.EnvelopeIdSpecified = true;
// we could have also deleted a specific document


DocNow.DeleteEnvelopeResult[] results = client.DeleteEnvelope(new DocNow.DeleteEnvelopeRequest[]{request});

if(result.Length > 0)
{
    if (result.Exceptions != null)
    {
        StringBuilder sb = new StringBuilder();
        foreach (DocNow.EnvelopeException exception in result.Exceptions)
        {
            sb.AppendFormat("{0} : {1}{2}", exception.Severity.ToString(), exception.Value, Environment.NewLine);
        }
        Console.WriteLine(sb.ToString());
    }
    else
    {
        // the result will return back result.EnvelopeId as confirmation
    }
}