I am using Authorizatio Code Grant
for authorization and wanted to send envelope
as draft
to other envelope recipient(editor). But in this case it is going to draft
of whoever is logging and sending envelope request. I can send that envelope
to other recipient's draft
simply using "Transfer Owenership" from sender's draft but wanted to automate this while sending envelope
request.
Here is the envelope
request I am sending:
try
{
// create the envelope definition
EnvelopeDefinition env = new EnvelopeDefinition();
env.EmailSubject = $"Please Sign - { DateTime.Now.ToString() }";
//Get document extension
var fileContentByteArray = System.IO.File.ReadAllBytes("D:\\ESign1.docx");
Document documentToSign = new Document
{
DocumentBase64 = Convert.ToBase64String(fileContentByteArray),
Name = "ESign1.docx",
FileExtension = "docx",
DocumentId = "1"
};
env.Documents = new List<Document> { documentToSign };
var signatureHandler = new Editor
{
Email = "[email protected]",
RecipientId = "1",
RoutingOrder = "1",
};
List<Signer> signers = new List<Signer>();
signers.Add(new Signer { Email = "[email protected]", Name = "xyz", RecipientId = "3", RoutingOrder = "3" });
signers.Add(new Signer { Email = "[email protected]", Name = "abc", RecipientId = "2", RoutingOrder = "2" });
// Add the recipients to the envelope object
Recipients recipients = new Recipients
{
Editors = new List<Editor> { signatureHandler },
Signers = signers
};
//Attache all recipients to envelope
env.Recipients = recipients;
//Webhook to listen envelope status
EventNotification eventNotification = new EventNotification
{
IncludeDocuments = "true",
IncludeDocumentFields = "true",
IncludeTimeZone = "true",
Url = "https://webhook-endpoint",
LoggingEnabled = "true",
EnvelopeEvents = new List<EnvelopeEvent>
{
new EnvelopeEvent{ EnvelopeEventStatusCode = "completed", IncludeDocuments = "true" }
}
};
env.EventNotification = eventNotification;
env.Status = "created";
var config = new Configuration(baseUrl);
config.AddDefaultHeader("Authorization", "Bearer " + access_token);
var apiClient = new ApiClient(baseUrl)
{
Configuration = config
};
EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
EnvelopeSummary result = envelopesApi.CreateEnvelopeAsync(account_id, env).Result;
}
catch (Exception ex)
{
}