kbessette

GetUpdatedPackagesWithinDateRange Unhandled Exception

0 votes
I'm having some difficulty implementing DownloadDocumentsDateRange posted previously in this forum. When the following code is executed the EslClient.PackageService.GetUpdatedPackagesWithinDateRange function throws an unhandled exception stating that an unexpected character was encountered while parsing value. I assume the string it's trying to parse is the response from eSignLive but I'm at a loss on how to debug it. Is there a way to capture and view this response? Is there documentation on the EslClient class that could shed light on what value the GetUpdatedPackagesWithinDateRange is expecting?
using System;
using System.IO;
using System.Threading;
using Silanis.ESL.SDK;
using System.Diagnostics;
using Silanis.ESL.SDK.Builder;



namespace DownloadDocumentsDateRange
{
    class DownloadDocuments
    {
        public static void Main(string[] args)
        {
            //API Identification Strings
            String apiUrl = "https://sandbox.esignlive.com/api";
            String apiKey = "***Redacted***";

            //Proxy info
            string httpProxyURL = "***Redacted***";
            int httpProxyPort = ***Redacted***;
            
            //Build Proxy Configuration
            ProxyConfiguration httpProxyConfiguration = ProxyConfigurationBuilder.NewProxyConfiguration()
            .WithHttpHost(httpProxyURL)
            .WithHttpPort(httpProxyPort)
            .Build();

            //Set EslClient
            EslClient eslClient = new EslClient(apiKey, apiUrl, httpProxyConfiguration);

            //starting point to retrieve completed packages
            int index = 1;

            //Retrieve first 50 completed packages. Packages are returned as a page from eSignLive.
            Page completedPackages = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.COMPLETED, new PageRequest(index, 50), DateTime.Today.AddDays(-30), DateTime.Now);

            while (index 

Here's the full stack trace.

Silanis.ESL.SDK.EslException was unhandled
  HResult=-2146233088
  Message=Could not get package list. Exception: Unexpected character encountered while parsing value: <. path="" line="" position="" source="Silanis.ESL" stacktrace:="" at="" silanis.esl.sdk.services.packageservice.getupdatedpackageswithindaterange="" status="" pagerequest="" request="" datetime="" from="" to="" downloaddocumentsdaterange.downloaddocuments.main="" args="" in="" system.appdomain._nexecuteassembly="" assembly="" string="" system.appdomain.executeassembly="" assemblyfile="" evidence="" assemblysecurity="" microsoft.visualstudio.hostingprocess.hostproc.runusersassembly="" system.threading.threadhelper.threadstart_context="" state="" system.threading.executioncontext.runinternal="" executioncontext="" contextcallback="" callback="" object="" boolean="" preservesyncctx="" system.threading.executioncontext.run="" system.threading.threadhelper.threadstart="" innerexception:="" hresult="-2146233088" linenumber="0" lineposition="0" message="Unexpected" character="" encountered="" while="" parsing="" value:="" newtonsoft.json.jsontextreader.parsevalue="" newtonsoft.json.jsontextreader.readinternal="" newtonsoft.json.jsontextreader.read="" newtonsoft.json.serialization.jsonserializerinternalreader.readfortype="" reader="" jsoncontract="" contract="" hasconverter="" newtonsoft.json.serialization.jsonserializerinternalreader.deserialize="" type="" objecttype="" checkadditionalcontent="" newtonsoft.json.jsonserializer.deserializeinternal="" newtonsoft.json.jsonconvert.deserializeobject="" value="" jsonserializersettings="" settings="" silanis.esl.sdk.eslserverexception..ctor="" errordetails="" webexception="" cause="" silanis.esl.sdk.internal.httpmethods.gethttpjson="" apitoken="" accepttype="" silanis.esl.sdk.restclient.get="">

Thanks for taking a look!

Approved Answer

Reply to: GetUpdatedPackagesWithinDateRange Unhandled Exception

0 votes
Are you able to do any other calls? Could you try a simple GetApplicationVersion() without the use of a proxy:
eslClient.SystemService.GetApplicationVersion();
Haris Haidary OneSpan Technical Consultant

Reply to: GetUpdatedPackagesWithinDateRange Unhandled Exception

0 votes
Hi there, Did you try getting the updated packages without the use of a proxy?
Haris Haidary OneSpan Technical Consultant

Reply to: GetUpdatedPackagesWithinDateRange Unhandled Exception

0 votes
Hi Haris, Thanks for the suggestion! I've commented out the proxy info and removed httpProxyConfiguration from the instantiation of eslClient. Now I'm getting a new exception from the same line of code, see below. Attached is the stdout.
using System;
using System.IO;
using System.Threading;
using Silanis.ESL.SDK;
using System.Diagnostics;

namespace DownloadDocumentsDateRange
{
    class DownloadDocuments
    {
        public static void Main(string[] args)
        {
            //API Identification Strings
            String apiUrl = "https://sandbox.esignlive.com/api";
            String apiKey = "***Redacted***";

             /*
             //Proxy info
             string httpProxyURL = "";
             int httpProxyPort = ;

             //Build Proxy Configuration
             ProxyConfiguration httpProxyConfiguration = ProxyConfigurationBuilder.NewProxyConfiguration()
             .WithHttpHost(httpProxyURL)
             .WithHttpPort(httpProxyPort)
             .Build();

             //Create EslClient
             EslClient eslClient = new EslClient(apiKey, apiUrl, httpProxyConfiguration);
             */

            EslClient eslClient = new EslClient(apiKey, apiUrl);

            //starting point to retrieve completed packages
            int index = 1;

            //Retrieve first 50 completed packages. Packages are returned as a page from eSignLive.
            Page completedPackages = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.COMPLETED, new PageRequest(index, 50), DateTime.Today.AddDays(-30), DateTime.Now);
            
            while (index 

Here's the new exception.

Silanis.ESL.SDK.EslException was unhandled
  HResult=-2146233088
  Message=Could not get package list. Exception: Object reference not set to an instance of an object.
  Source=Silanis.ESL
  StackTrace:
       at Silanis.ESL.SDK.Services.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus status, PageRequest request, DateTime from, DateTime to)
       at DownloadDocumentsDateRange.DownloadDocuments.Main(String[] args) in ***Redacted***:line 38
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
       HResult=-2147467261
       Message=Object reference not set to an instance of an object.
       Source=Silanis.ESL
       StackTrace:
            at Silanis.ESL.SDK.Internal.HttpMethods.GetHttpJson(String apiToken, String path, String acceptType)
            at Silanis.ESL.SDK.RestClient.Get(String path)
            at Silanis.ESL.SDK.Services.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus status, PageRequest request, DateTime from, DateTime to)
       InnerException: 
Thanks, Keith

Attachments

Reply to: GetUpdatedPackagesWithinDateRange Unhandled Exception

0 votes
No, it appears I can't make any other calls without the proxy. Same "Object reference not set to an instance of an object" exception. Adding the proxy info back in yields the "Unexpected character encountered while parsing value" error again. It's starting to appear that our security is preventing the call from leaving our network. I'll work in that direction. I'll update this thread with what I find. Thanks for the help!

Reply to: GetUpdatedPackagesWithinDateRange Unhandled Exception

0 votes
Sounds good. Let me know.
Haris Haidary OneSpan Technical Consultant

Reply to: GetUpdatedPackagesWithinDateRange Unhandled Exception

0 votes
Sure enough, it was security related. I needed to add authentication for the proxy. Thanks again!

Reply to: GetUpdatedPackagesWithinDateRange Unhandled Exception

0 votes
Glad you were able to resolve it :)
Haris Haidary OneSpan Technical Consultant

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off