GetUpdatedPackagesWithinDateRange Error message
Thursday, February 7, 2019 at 04:31amI have this code as was suggested by OneSpan for retrieving "GetUpdatedPackagesWithinDateRange" but I am getting an error on this line.
Page completed_packages = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.SENT, new PageRequest(index, 10), DateTime.Now.AddDays(-10), DateTime.Now);
using System;
using System.Threading;
using Silanis.ESL.SDK;
using System.Diagnostics;
using System.IO;
namespace GetDocumentsFromELive
{
class LoadFiles
{
private static String apiUrl = "https://sandbox.esignlive.com";
private static string apiKey = "api_keys";
public static void Main(string[] args)
{
EslClient eslClient = new EslClient(apiKey, apiUrl);
int index = 1;
Page completed_packages = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.SENT, new PageRequest(index, 10), DateTime.Now.AddDays(-10), DateTime.Now);
while (index = completed_packages.TotalElements)
{
foreach (DocumentPackage package in completed_packages)
{
Debug.WriteLine("Downloading package: " + package.Id + "...");
byte[] zipContent = eslClient.DownloadZippedDocuments(package.Id);
File.WriteAllBytes(Directory.GetCurrentDirectory() + "/package-documents-" + package.Id.ToString() + ".zip", zipContent);
index++;
Thread.Sleep(1000);
}
completed_packages = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus.COMPLETED, new PageRequest(index, 50), DateTime.Today.AddDays(-7), DateTime.Now);
}
}
}
}
----------------------------------
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 H:\Code\Downloader\eSignLiveDocumentDownload\DownloadDocumentsNet.cs:line 24
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:
-------------------------------------------------------------
Above is the error I was getting on my work computer Network. When I ran the same code on my private laptop, I got different error messages like the one below:
--------------------------------------------------------------
Silanis.ESL.SDK.EslServerException occurred
HResult=0x80131500
Message=Could not get package list. Exception: The remote server returned an error: (401) Unauthorized. HTTP GET on URI https://sandbox.esignlive.com/packages?query=SENT&from=1&to=10&lastUpdatedStartDate=2019-01-28T14:46:01Z&lastUpdatedEndDate=2019-02-07T14:46:01Z. Optional details: {"messageKey":"error.unauthorised.accountSuspended","code":401,"name":"Unauthorized","message":"Cannot create session with suspended account."}
Source=Silanis.ESL
StackTrace:
at Silanis.ESL.SDK.Services.PackageService.GetUpdatedPackagesWithinDateRange(DocumentPackageStatus status, PageRequest request, DateTime from, DateTime to)
at GetDocumentsFromELive.Program.Main(String[] args) in C:\dev\ECM\GetDocumentsFromELive\GetDocumentsFromELive\LoadFiles.cs:line 27
Inner Exception 1:
EslServerException: The remote server returned an error: (401) Unauthorized. HTTP GET on URI https://sandbox.esignlive.com/packages?query=SENT&from=1&to=10&lastUpdatedStartDate=2019-01-28T14:46:01Z&lastUpdatedEndDate=2019-02-07T14:46:01Z. Optional details: {"messageKey":"error.unauthorised.accountSuspended","code":401,"name":"Unauthorized","message":"Cannot create session with suspended account."}
Inner Exception 2:
WebException: The remote server returned an error: (401) Unauthorized.
-------------------------------------
Please any contribution will be helpful.
Thanks!
Nick
Reply to: GetUpdatedPackagesWithinDateRange Error message
Thursday, February 7, 2019 at 05:59amReply to: GetUpdatedPackagesWithinDateRange Error message
Thursday, February 7, 2019 at 06:52amReply to: GetUpdatedPackagesWithinDateRange Error message
Thursday, February 7, 2019 at 06:59amReply to: GetUpdatedPackagesWithinDateRange Error message
Thursday, February 7, 2019 at 07:02am