MTerry01 | Posts: 1

OssClient.DownloadZippedDocuments Method Giving Error

0 votes

The OssClient.DownloadZippedDocuments method is throwing the following error sporadically.  The code below that contains this method works the majority of the time.  I would appreciate any suggestions on why this error happens every once and a while. 

Could not download the documents to a zip file. Exception: Object reference not set to an instance of an object.

 

The code below is throwing the error at the DownloadZippedDocuments method:

//OneSpan connection
OssClient eslClient = new OssClient(C.OSS.API_KEY, C.OSS.API_URL);

//package Id
PackageId pkgId = new PackageId(packageID);

//download zipped documents 
byte[] content = eslClient.DownloadZippedDocuments(pkgId);

//directory path
string zipFileLocation = OneSpan_Listener.Properties.Settings.Default.DocumentsStoragePath + pkgId + "\\";
string zipFile = zipFileLocation + "\\" + pkgId + "_" + DateTime.Now.ToString("yyyy_MM_dd") + ".zip";               

//folder exists check
if (Directory.Exists(zipFileLocation)) 
{
 //delete folder
 Directory.Delete(zipFileLocation, true);
}

//index file check
fullFileName = indFilePath + indFileName + indFileNameExt;
if (File.Exists(fullFileName))
{
 //delete index file
 File.Delete(fullFileName);
}

//zip file download
Directory.CreateDirectory(zipFileLocation);
File.WriteAllBytes(zipFile, content);

//expand zip file                
ZipFile.ExtractToDirectory(zipFile, zipFileLocation);
 


Duo_Liang | Posts: 3776

Reply to: OssClient.DownloadZippedDocuments Method Giving Error

0 votes

Hi MTerry01,

 

Thanks for your post!

From my previous experience, this "Object reference not set to an instance of an object." error happens at local or before establishing connection with OneSpan Sign system (because it's not an API error returned from OSS server) and could typically caused because of connection issue (TLS version mismatch or proxy settings), or server downtime.

Hence, you might want to

(1) explicitly specify the TLS version as 1.2 with this code:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

(2) implement a retry mechanism

(3) after failed certain times, check the connection to OSS server, you could use this SDK function:
string applicationVersion = eslClient.SystemService.GetApplicationVersion();

It's invoking this API behind the scene: GET /api/sysinfo

(4) fill in a support ticket and provide the timestamp when the call failed to see if there's any downtime during that period of time (but this probably won't be very helpful as the error happened before the connection established)

 

Duo


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