public static void Execute() { // Enter your DocuSign credentials var credentials = new DocusignQuickStart.DocusignCredentials { Username = "******", Password = "******", IntegratorKey = "81f3bae3-f472-4a51-8d5f-e966f74cb0ab" }; // specify the document (file) we want signed string SignTest1File = @"C:\Users\callu_000\Documents\UD Group\Docusign\CNG\CNG Contract.pdf"; // Enter recipient (signer) name and email address string recipientName = "Callum Rigby"; string recipientEmail = "*****@*****.**"; string recipientName2 = "John Smith"; string recipientEmail2 = "*****@*****.**"; // instantiate api client with appropriate environment (for production change to www.docusign.net/restapi) string basePath = "https://demo.docusign.net/restapi"; // instantiate a new api client var apiClient = new ApiClient(basePath); // set client in global config so we don't need to pass it to each API object Configuration.Default.ApiClient = apiClient; string authHeader = JsonConvert.SerializeObject(credentials); //DocusignCredentials cred = JsonConvert.DeserializeObject<DocusignCredentials>(authHeader); Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader); // we will retrieve this from the login() results string accountId = null; // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object var authApi = new AuthenticationApi(); LoginInformation loginInfo = authApi.Login(); // user might be a member of multiple accounts accountId = loginInfo.LoginAccounts[0].AccountId; Console.WriteLine("LoginInformation: {0}", loginInfo.ToJson()); // Read a file from disk to use as a document byte[] fileBytes = File.ReadAllBytes(SignTest1File); var envDef = new EnvelopeDefinition(); envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc"; // Add a document to the envelope var doc = new Document(); doc.DocumentBase64 = Convert.ToBase64String(fileBytes); doc.Name = "TestFile.pdf"; doc.DocumentId = "1"; envDef.Documents = new List<Document>(); envDef.Documents.Add(doc); // Add a recipient to sign the documeent var signer = new Signer(); signer.Name = recipientName; signer.Email = recipientEmail; signer.RecipientId = "1"; signer.RoutingOrder = "1"; var signer2 = new Signer(); signer2.Name = recipientName2; signer2.Email = recipientEmail2; signer2.RecipientId = "2"; signer.RoutingOrder = "2"; // Create a |SignHere| tab somewhere on the document for the recipient to sign signer.Tabs = new Tabs(); signer.Tabs.SignHereTabs = new List<SignHere>(); var signHere = new SignHere(); signHere.DocumentId = "1"; signHere.PageNumber = "1"; signHere.RecipientId = "1"; signHere.XPosition = "100"; signHere.YPosition = "150"; signer.Tabs.SignHereTabs.Add(signHere); signer2.Tabs = new Tabs(); signer2.Tabs.SignHereTabs = new List<SignHere>(); var signHere2 = new SignHere(); signHere.DocumentId = "1"; signHere.PageNumber = "1"; signHere.RecipientId = "2"; signHere.XPosition = "100"; signHere.YPosition = "200"; signer2.Tabs.SignHereTabs.Add(signHere); envDef.Recipients = new Recipients(); envDef.Recipients.Signers = new List<Signer>(); envDef.Recipients.Signers.Add(signer); envDef.Recipients.Signers.Add(signer2); // set envelope status to "sent" to immediately send the signature request envDef.Status = "sent"; // Use the EnvelopesApi to send the signature request! var envelopesApi = new EnvelopesApi(); EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef); // print the JSON response Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary)); Console.Read(); }
static void Main(string[] args) { // Enter your DocuSign credentials string Username = "******"; string Password = "******"; string IntegratorKey = "[INTEGRATOR_KEY]"; // specify the document (file) we want signed string SignTest1File = @"[PATH/TO/DOCUMENT/TEST.PDF]"; // Enter recipient (signer) name and email address string recipientName = "[SIGNER_NAME]"; string recipientEmail = "[SIGNER_EMAIL]"; // instantiate api client with appropriate environment (for production change to www.docusign.net/restapi) string basePath = "https://demo.docusign.net/restapi"; // instantiate a new api client ApiClient apiClient = new ApiClient(basePath); // set client in global config so we don't need to pass it to each API object Configuration.Default.ApiClient = apiClient; string authHeader = "{\"Username\":\"" + Username + "\", \"Password\":\"" + Password + "\", \"IntegratorKey\":\"" + IntegratorKey + "\"}"; Configuration.Default.AddDefaultHeader("X-DocuSign-Authentication", authHeader); // we will retrieve this from the login() results string accountId = null; // the authentication api uses the apiClient (and X-DocuSign-Authentication header) that are set in Configuration object AuthenticationApi authApi = new AuthenticationApi(); LoginInformation loginInfo = authApi.Login(); // user might be a member of multiple accounts accountId = loginInfo.LoginAccounts[0].AccountId; Console.WriteLine("LoginInformation: {0}", loginInfo.ToJson()); // Read a file from disk to use as a document byte[] fileBytes = File.ReadAllBytes(SignTest1File); EnvelopeDefinition envDef = new EnvelopeDefinition(); envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc"; // Add a document to the envelope Document doc = new Document(); doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes); doc.Name = "TestFile.pdf"; doc.DocumentId = "1"; envDef.Documents = new List<Document>(); envDef.Documents.Add(doc); // Add a recipient to sign the documeent Signer signer = new Signer(); signer.Name = recipientName; signer.Email = recipientEmail; signer.RecipientId = "1"; // Create a |SignHere| tab somewhere on the document for the recipient to sign signer.Tabs = new Tabs(); signer.Tabs.SignHereTabs = new List<SignHere>(); SignHere signHere = new SignHere(); signHere.DocumentId = "1"; signHere.PageNumber = "1"; signHere.RecipientId = "1"; signHere.XPosition = "100"; signHere.YPosition = "150"; signer.Tabs.SignHereTabs.Add(signHere); envDef.Recipients = new Recipients(); envDef.Recipients.Signers = new List<Signer>(); envDef.Recipients.Signers.Add(signer); // set envelope status to "sent" to immediately send the signature request envDef.Status = "sent"; // Use the EnvelopesApi to send the signature request! EnvelopesApi envelopesApi = new EnvelopesApi(); EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountId, envDef); // print the JSON response Console.WriteLine("EnvelopeSummary:\n{0}", JsonConvert.SerializeObject(envelopeSummary)); Console.Read(); }