Pankaj Bhasin
Pankaj Bhasin

Reputation: 21

DocuSign.eSign.Client.ApiException: Unhandled response type

Trying to use DocuSign.eSign Nuget package 5.2.0.

Getting Exception (DocuSign.eSign.Client.ApiException: Unhandled response type.) at line 53 in my code below.

Line 52: var envelopesApi = new EnvelopesApi(apiClient); Line 53: EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelope);

[ApiException: Unhandled response type.] DocuSign.eSign.Client.ApiClient.Deserialize(Byte[] content, Type type, IList1 headers) +261 DocuSign.eSign.Api.EnvelopesApi.CreateEnvelopeWithHttpInfo(String accountId, EnvelopeDefinition envelopeDefinition, CreateEnvelopeOptions options) +3410 DocuSign.eSign.Api.EnvelopesApi.CreateEnvelope(String accountId, EnvelopeDefinition envelopeDefinition, CreateEnvelopeOptions options) +83 motr.docusign.DocumentSigningManager.DoWork(String signerEmail, String signerName, String accessToken, String basePath, String accountId) in D:\Pankaj\Dev\mot-r\motr.docusign\Class1.cs:53 motr.Web.ApiControllers.DSConnectController.SendDocument() in D:\Pankaj\Dev\mot-r\motr.Web\ApiControllers\DSConnectController.cs:132 lambda_method(Closure , ControllerBase , Object[] ) +87 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +229 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +35 System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39 System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +77 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3d() +72 System.Web.Mvc.Async.<>c__DisplayClass46.b__3f() +396 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.<>c__DisplayClass2b.b__1c() +38 System.Web.Mvc.Async.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult) +188 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38 System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +32 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +73 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38 System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +46 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +431 System.Web.<>c__DisplayClass285_0.b__0() +38 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +11857001 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +158

Tried using older version as far back as 4.1.0 and get the same issue with all of them.

I am using one of the sample code for .netCore and trying to use it with .Net Framework 4.8 using the available Nuget Package.

Here is my code:

using DocuSign.eSign.Api;
using DocuSign.eSign.Client;
using DocuSign.eSign.Model;
using motr.docusign.model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace motr.docusign
{
    public class DocumentSigningManager
    {

        private string dsPingUrl;
        private string signerClientId = "1000";
        private string dsReturnUrl;
        private DSConfiguration Config;
        private IRequestItemsService RequestItemsService;

        public DocumentSigningManager()
        {
            
            Config = new DSConfiguration();
            dsPingUrl = Config.AppUrl + "/";
            dsReturnUrl = Config.AppUrl + "/dsReturn";
            
        }

        public string DoWork(string signerEmail, string signerName,
            string accessToken, string basePath, string accountId)
        {
            
            EnvelopeDefinition envelope = MakeEnvelope(signerEmail, signerName);

            
            var apiClient = new DocuSign.eSign.Client.ApiClient(basePath);
            apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
            
            var envelopesApi = new EnvelopesApi(apiClient);
            EnvelopeSummary results = envelopesApi.CreateEnvelope(accountId, envelope);
            string envelopeId = results.EnvelopeId;

            
            RecipientViewRequest viewRequest = MakeRecipientViewRequest(signerEmail, signerName);
            
            ViewUrl results1 = envelopesApi.CreateRecipientView(accountId, envelopeId, viewRequest);

            string redirectUrl = results1.Url;
            return redirectUrl;
        }

        private RecipientViewRequest MakeRecipientViewRequest(string signerEmail, string signerName)
        {
           
            RecipientViewRequest viewRequest = new RecipientViewRequest();
            
            viewRequest.ReturnUrl = dsReturnUrl + "?state=123";

            viewRequest.AuthenticationMethod = "none";

            viewRequest.Email = signerEmail;
            viewRequest.UserName = signerName;
            viewRequest.ClientUserId = signerClientId;

            viewRequest.PingFrequency = "600";
                                               
            viewRequest.PingUrl = dsPingUrl;

            return viewRequest;
        }

        private EnvelopeDefinition MakeEnvelope(string signerEmail, string signerName)
        {
            
            EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
            envelopeDefinition.EmailSubject = "Please sign this document";
            
            Signer signer1 = new Signer
            {
                Email = signerEmail,
                Name = signerName,
                ClientUserId = signerClientId,
                RecipientId = "1"
            };

            Recipients recipients = new Recipients
            {
                Signers = new List<Signer> { signer1 }
            };
            envelopeDefinition.Recipients = recipients;

            envelopeDefinition.Status = "sent";

            return envelopeDefinition;
        }
    }
}

Upvotes: 1

Views: 841

Answers (1)

Geofferyp
Geofferyp

Reputation: 111

I tested a .Net Framework 4.8 application. It works, so that is not the problem. Most likely the base path is incorrect, so you get unexpected response. Correct basepath for demo is https://demo.docusign.net/restapi. When you solve this your code will generate a NO_DOCUMENT_RECEIVED error. You are not defining a document before sending.

Upvotes: 2

Related Questions