C# SDK setup and configuration
Adding the SDK to your project
The C# eSignature SDK is provided as a NuGet package named DocuSign.eSign.dll. By default, you will always get the latest stable version of the SDK. Prerelease versions (either release candidate (rc) or beta) can also be downloaded as shown below.
There are two ways to add the package to your project: via the Visual Studio UI or the command line.
Adding the C# SDK to your project using the Visual Studio UI
-
Open Visual Studio and load the solution you wish to use.
-
Open the Solution Explorer window and right-click the desired project in the solution.
-
Select Manage NuGet Packages… (shown below).
- In the NuGet Package Manager window, select the Browse tab on the left.
- In the Search textbox, enter “Docusign” to find all Docusign-related packages. DocuSign.eSign.dll “by Docusign” (publisher) should be displayed first in the search results. Select it.
- Select Install to install the latest version of the package.
Note: You can install earlier versions by expanding the drop-down menu to the right of Version. You can also install release candidate (rc) and beta versions by selecting the Include prerelease checkbox to the right of the Search textbox.
- Acknowledge the license agreement by selecting I Accept on the License Acceptance screen.
You have now successfully downloaded, configured, and installed the Docusign eSignature SDK for your project. To confirm the package is available in your project, you can go back to the Solution Explorer window and expand the Dependencies > Packages section of the project. You should see DocuSign.eSign.dll (version number) listed.
Note: If you expand the DocuSign.eSign.dll package, you will see the additional dependencies that are automatically installed by the NuGet package manager.
Adding the C# SDK to your project using the command line
-
Open the NuGet Package Manager command line from the Visual Studio menu bar by selecting Tools > NuGet Package Manager > Package Manager Console.
From the Package Manager Console, run the following command:
The command above will automatically install the latest stable version. If desired, you can specify a specific version by using the -Version switch. For example, this command installs version 5.2.0 of the Docusign C# eSignature package:
Including the SDK library
After you have installed the DocuSign.eSign.dll package, you will need to find the public classes that are required to complete various eSignature tasks. To do that, add the main namespaces as using statements in your C# code.
Here are the three main using statements for the commonly required namespaces:
DocuSign.eSign.Api namespace
This namespace is used for endpoint categories. Each class under this namespace corresponds to one of the categories listed in the left menu of the Docusign eSignature REST API Reference. You will need to use this namespace to make calls to the public methods that initiate REST API calls to the Docusign eSignature REST API.
Note: Hereafter in the SDK documentation, the term “API object” will refer to eSignature REST API Reference objects.
An API category contains all methods for each API resource in that category. For example, the C# SDK EnvelopesApi class includes the CreateEnvelope method. This method corresponds to the create method of the API Envelopes resource.
The C# SDK method names roughly correspond to the API Resource:method names.
The API Resource:method page for each endpoint lists the API SDK Method in the SDK Method box. The C# method name will be the PascalCase version of the API SDK Method name. For example, the API SDK Method Envelopes::createEnvelope, listed toward the bottom of the Envelopes:create page, is the C# method CreateEnvelope.
Some API endpoints also use HTTP query parameters. Within the API, such query parameters use snake_case. For example, the Envelopes:create API method includes an optional query parameter, change_routing_order. Within the SDK, the API’s query parameters are added as an elective options parameter after the request object.
Example: The CreateEnvelope method signature is:
The CreateEnvelopeOptions class is used to set the API method’s query parameters. The class is defined as:
The class attributes in camelCase correspond to the API endpoint’s query parameters.
DocuSign.eSign.Model namespace
This namespace includes the data structures used for sending and receiving data from the eSignature API endpoints. By using these classes instead of generic JSON objects, C# developers can develop with the Docusign eSignature API more easily and quickly than by using JSON directly.
There’s a one-to-one correspondence between the objects described in the API Reference and the classes in the DocuSign.eSign.Model namespace. The API object names use flatcase (all lowercase without spaces) while the corresponding SDK models use PascalCase. For example, the API object paymentgatewayaccount corresponds to the C# model PaymentGatewayAccount.
Note: The API object name is often not the same as the corresponding model in the C# SDK.
Object attribute names in the API use camelCase. The corresponding properties of the C# SDK are in PascalCase.
DocuSign.eSign.Client namespace
This namespace contains the classes needed to manage the overall API experience. These classes handle instantiating a client element to make API calls, authentication, and exception handling. You will need to include this namespace to be able to use the Docusign eSignature API correctly.
Using the SDK
To make eSignature REST API calls with the SDK, you need:
- A current
accessToken. - The
basePathfor the API call. - For most API calls, you’ll also need the relevant
accountId. Note that it is common for a user to be a member of multiple accounts.
Modifying the default HTTP Request timeout
By default, ASP.NET applications have a 90-second timeout for HTTP requests. In rare cases API calls may take longer, and you may need to increase the timeout to accommodate these calls. Follow instructions provided by Microsoft at Request timed out error when you use the DataAdapter method in an ASP.NET application to increase the timeout period for HTTP requests made from your application when using the Docusign C# SDK.