Ning | Posts: 4

Can't get all the package IDs

0 votes
Hi, I am trying to get all the package IDs from one account. For some reason, I only get one package ID comes back, even the count shows me as 3. The is the url i have tried 'https://sandbox.esignlive.com/api/packages'. Please see the attached screenshot for the result I get from Postman. Can anyone please help take a look at this? Thanks a lot, Ning

Attachments
Approved Answer
harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Unfortunately, 100 packages is the maximum you can retrieve per request. The reason behind this is because if we allow users to retrieve thousands of packages in one call, it would put a huge load on our servers. If you want to retrieve all your packages, you will need to do so in a loop: from 0 to 99, from 100 to 199, etc... As for retrieving completed packages, use the "query" parameter:
https://sandbox.esignlive.com/api/packages?from=0&to=99&query=completed
I'm not sure why predefined doesn't work. I'll have to look into it. You might also want to have a look at the completion report. If you're only interested in the package id, you should use the completion report as it returns less data. https://developer.esignlive.com/guides/feature-guides/completion-report/ http://docs.esignlive.com/content/c_integrator_s_guide/rest_api/reports.htm#Retrieve2

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

1 votes
Hi Ning, You will need to add additional parameters in your request in order to retrieve all your packages. For example:
GET https://sandbox.esignlive.com/api/packages?from=0&to=100
The call above will return you the first 100 packages (maximum number per call). You can have a look at our documentation for a complete list of parameters available to you: http://docs.esignlive.com/content/c_integrator_s_guide/rest_api/packages.htm#Retrieve

Ning | Posts: 4

Reply to: Can't get all the package IDs

0 votes
Hi Haris, Thanks for your quick help!! Yes, I have tried to add 'from' and 'to' parameters, all 3 package ids will be returned. But this way has a limitation(max size is 100), right? Is there any way I can get all the package Ids back at one call when there are hundreds or thousands packages? Also I have tried to get the first 100 completed packages through URL' https://sandbox.esignlive.com/api/packages?predefined=completed&from=0&to=100' But I notice even the status is 'DRAFT', this package is also returned. Please see my attached screenshot. I am not sure if I use the parameters right, can you please suggest? Thanks a lot, Ning

Ning | Posts: 4

Reply to: Can't get all the package IDs

0 votes
Thank you very much, Haris!! 'query' parameter works well! The API document didn't mention 'completed' is one of the option for 'query' parameter, it will be helpful if the document can add this. I just tried completion report, it definitely returns less data than using Package. Very useful. I have two other questions as below, I don't know do I need to create two new posts. If needed, please let me know. 1) Based on the link http://docs.esignlive.com/content/c_integrator_s_guide/rest_api/packages.htm#Delete, we know there is no response after delete package request has been made. Is there any way I can make sure the delete request has been completed? 2) Will there be any REST API request code difference between two sandbox ‘https://sandbox.esignlive.com/api/’ and ‘https://sandbox.e-signlive.com/api/’? Thanks a lot, Ning

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Based on the link http://docs.esignlive.com/content/c_integrator_s_guide/rest_api/packages.htm#Delete, we know there is no response after delete package request has been made. Is there any way I can make sure the delete request has been completed?

If you get a 200 response after making the DELETE request, you can be pretty much assured that the package is deleted. Someone else asked a similar question and you can read the complete answer from my colleague here: https://community.onespan.com/forum/how-do-i-tell-if-delete-package-failed

Will there be any REST API request code difference between two sandbox "https://sandbox.esignlive.com/api/" and "https://sandbox.e-signlive.com/api/"?

The short answer is no. Though, there are some features on sandbox.esignlive.com (version 11.2) that are not available on sandbox.e-signlive.com (version 10.13). For example, signing through the api. Pretty soon, everyone will be migrated to version 11 of esignlive. Therefore, I suggest you do your testing against version 11 :)


Ning | Posts: 4

Reply to: Can't get all the package IDs

0 votes
Got it! I really appreciate all your help!! Have a great long weekend!

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Thanks. You too!

shurley | Posts: 1

Reply to: Can't get all the package IDs

0 votes
Seems to me like “the short answer is YES” that there are differences. What version do the online docs at http://docs.esignlive.com/content/c_integrator_s_guide/rest_api/rest_api.htm represent and if it's not 11.2, is there another resource for the 11.2 API?

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
Please explain and show example code with sample output how to retrieve by looping 100 at a time. You say you can do it, but there is no documentation that supports what you are saying. The only optional parameters for the completion report is, from and to, and these are dates.

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Hi there, The idea is to use the "from" and "to" indexing parameters. You will simply need to create a loop that retrieves 50 packages at a time. Here's the basic idea:
int x = 0;
int y = 49;

GET https://sandbox.esignlive.com/api/packages?from=x&to=y;

while (packageCount > 0) {
     if(condition){
            //do something here
     }
     x+=50;
     y+=50;
     GET https://sandbox.esignlive.com/api/packages?from=x&to=y;

}

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
Ok, I will be more specific as to minimize confusion. At this time we have to manually receive a transactions report from eSL on request. But because we need this daily, we need to automate the process. At first, it was eSL's suggestion to use an existing API call to get that same information. So I tried doing that using several different ones, the closest to what we needed was the completion report. But that has a limit of 100. I've used the SDK and also tried directly calling the APIs, but none have return what is needed. Specifically, we are looking for an API that can retrieve by date range (in our example, the prior day) transaction statuses by using the update date. Example: if today is 9/29/2017, I would like to call an API that can retrieve the status information for packages that were updated on 9/28/2017. I don't want to return the entire JSON payload or only package names. We need the fields like we get in the transaction report or the completion report (most importantly needed are the Package Id, Status, and Update Date). I need this for ALL statuses, sent, draft, expired, completed....etc. We have thousands of transactions for any one day of processing, way above the 100 limit. In your response, It seems like you are talking about mixing parameters from different API reports. In my communications with eSL's Sam Habbab, Senior Product Mananger, he is being told from his R&D department that this can not be done and there is not an existing API to do this. He is asking them if they can change the 100 transaction limit. But that being said, I am still hopeful that you indicate that this still may be possible using existing APIs. It's also possible that we are just not on the same page as to what I am requesting and what you are answering. If you do know a way to accomplish this, it would really be appreciated. Let me know if you need more information or if there is a way I can work with you directly. If this forum is the only why to communicate, then that's fine also. Thank you for your attention to this.

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
So essentially, you need to run a daily report to get the following: package ids, status, and update date. Correct? Then you could probably get away with doing something like this:
            HttpClient httpClient = new HttpClient();
            httpClient.DefaultRequestHeaders.Add("Authorization", "Basic " + Properties.Settings.Default.key);
            httpClient.DefaultRequestHeaders.Add("Accept", "application/json");

            int x = 0;
            int y = 49;

            var response = httpClient.GetAsync(new Uri("https://sandbox.esignlive.com/api") + "/packages?from=" + x + "&to=" + y + "&lastUpdatedStartDate=2017-10-02&lastUpdatedEndDate=2017-10-03&query=draft").Result;
            JObject obj = JObject.Parse(response.Content.ReadAsStringAsync().Result);
            var packages = obj["results"];

            while(packages.Count() > 0)
            {
                foreach (var package in packages)
                {
                    Debug.WriteLine("Package Id: " + package["id"] + " Updated: " + package["status"]);
                }
                x += 50;
                y += 50;
                response = httpClient.GetAsync(new Uri("https://sandbox.esignlive.com/api") + "/packages?from=" + x + "&to=" + y + "&lastUpdatedStartDate=2017-10-02&lastUpdatedEndDate=2017-10-03&query=draft").Result;
                obj = JObject.Parse(response.Content.ReadAsStringAsync().Result);
                packages = obj["results"];
            }
Which will return you all packages in a given day per status. So, if you want to retrieve all statuses, then you will need to create a loop with the code above in order to go through each status.

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
Ok, now we are getting somewhere. This looks very promising. I have a question about the &query= parameter. What are all the valid values? I know I can do sent, completed, draft, etc... separately. But, when I put any other value("&query=blah") or even, no value("&query="), then I get all the statuses returned. Do you see a problem with using it this way? Returning all statuses is what I am looking for, so this looks like what I need.

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Those are optional parameters. I'm not sure if removing the query parameter will return you all statuses. You can try it out. If it doesn't, then you will have to loop through each status like I mentioned before.

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
If you refer back to my previous post on this subject, we had worked to successfully get the api working and sending the info that we needed. Everything was working great until recently, it stop working. Did something change there? Something with the authentication? this is my header info: private static string API_KEY = "our app key here"; private static string API_URL = "https://sandbox.esignlive.com/api"; HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Authorization", "Basic " + API_KEY); httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); this is the error it's now returning: System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream. at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult) at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) --- End of inner exception stack trace --- --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task`1.get_Result() at SDK.Examples.GetPackageData.Main(String[] args) in c:\Git\mytest4\mytest4\Program.cs:line 28 ---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream. at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult) at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) --- End of inner exception stack trace ------

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Hello, We disabled support for TLS 1.0 on sandbox last night. You will to upgrade to TLS version 1.1 or 1.2. Note that TLS 1.0 will also be disabled on production around March of next year.

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
Thanks for the info. We are using .net 4.5 code. I found this documention and added the SercurityProtocalType.Tls12 before the api connection, this fixed the issue: .NET 4.6 and above. You don’t need to do any additional work to support TLS 1.2, it’s supported by default. .NET 4.5. TLS 1.2 is supported, but it’s not a default protocol. You need to opt-in to use it. The following code will make TLS 1.2 default, make sure to execute it before making a connection to secured resource: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 .NET 4.0. TLS 1.2 is not supported, but if you have .NET 4.5 (or above) installed on the system then you still can opt in for TLS 1.2 even if your application framework doesn’t support it. The only problem is that SecurityProtocolType in .NET 4.0 doesn’t have an entry for TLS1.2, so we’d have to use a numerical representation of this enum value:ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; .NET 3.5 or below. TLS 1.2 is not supported (*) and there is no workaround. Upgrade your application to more recent version of the framework.

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Thanks for the info! :)

jimwooley | Posts: 6

Reply to: Can't get all the package IDs

0 votes
Is there a plan to update the .Net SDK to accomidate this change? Are you accepting external pull requests? I see 3 outstanding pull requests from some time ago. Also, what is the typical communication strategy around breaking changes like this?

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
I just noticed that this query does not return all statuses, for example There are no package ids returned where the package has been trashed. Is there a way to get those?

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Hi, Unfortunately, to retrieve trashed packages, you will need to use the REST API. Because trashed isn't a package status per say. It's a flag in the package json. For example, if you trash a completed package, the status is still completed. However, if you query completed packages, you still don't get trashed packages. This might be a bug on our end. I will investigate and get back to you.

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
Yes, I realize that "trashed" is not a status change, but that it is an indicator. But it should still return the package regardless of the status. The status would still be Sent, or Opted_Out, or something. I have a concern of the timeline of a solution to this because we are using the api query in our project and are in our testing phase. it is important to have this resolved quickly. What can I do to insure this gets resolved soon. Do I need a ticket number or open a case to be escalated? Is this something you are handling on your end? If so, do you have something I can reference so I can coordinate with our account rep?

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
If you're using the API, you can retrieve the trashed packages like so: https://sandbox.esignlive.com/api/packages?query=trashed I'm sorry I got confused because there was a mention of the .NET SDK above and I thought you were asking on how to retrieve trashed packages with it.

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
Thanks for the response. I am able to get the trashed transactions.

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
Ok, Now I have a new issue. From using the API and comparing it to the Transaction report sent from esignlive for the same package id. the update dates have different values. As an example. Package completed 12/1/2017 at 1:00 pm. the transaction report from esignlive will reflect that date. But if the signing session is accessed, or documents are download, or any activity after the completion. The report from esignlive still has the update date/time as 12/1/2017 at 1:00 pm. But the API return the update date/time of the last activity for the package. So, if someone signed into to see the document three days later at 2, then the API update date is 12/3/2017 at 2 pm. Because of this mismatch, more than a 3rd of all transactions between the two reports don't match between the update dates. From the API response, we us the package id, date, and status: package["id"], package["updated"], package["status"]. Is there another parameter that would match the update date from the esignlive's report update date? Or why don't these match?

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Hi, Transaction reports from eSignLive are generated on the 1st of every month. However, it does take some time to be delivered due to the huge amount of reports that need to be run. Hence, you should run your report through the API on the 1st of every month as well.

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
Discovered a new issue using this API - this is unexpected and not good. In addition to returning packages for the selected date, it is randomly returning packages from other dates. Can you explain why this would happen? We are now using this in production and this is causing an issue with out balancing routine. For example I requested all records with update date of 1/19/2018. The API returned 3744 records for that date (great!), but it also returned 4 for 1/20/2018, 2 for 1/21/2018, 12 for 1/22/2018, 3 for 1/23/2018, 2 for 1/24/2018, and 2 for 1/25/2018 - this is not good!

harishaidary | Posts: 1812

Reply to: Can't get all the package IDs

0 votes
Hi tiberiuswest, One quick question, are you specifying a "lastUpdatedEndDate" in your API request? Because if you omit that parameter, you will be returned all packages starting from the start date.

tiberiuswest | Posts: 12

Reply to: Can't get all the package IDs

0 votes
yes, I always include a start and end date. public static void Main(string[] args) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Authorization", "Basic " + API_KEY); httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); var x = 0; var y = 49; const string dateFrom = "2018-01-19"; const string dateTo = "2018-01-19"; var response = httpClient.GetAsync(new Uri(API_URL) + "/packages?from=" + x + "&to=" + y + "&lastUpdatedStartDate=" + dateFrom + "&lastUpdatedEndDate=" + dateTo + "&query=").Result; JObject obj = JObject.Parse(response.Content.ReadAsStringAsync().Result); var packages = obj["results"]; var outputCSVfilePath = @"C:\test\NewBalancingRecords\ESL_2018_JAN18.csv"; StreamWriter swFile = new StreamWriter(outputCSVfilePath, false); swFile.WriteLine("{0},{1},{2}", "Package ID", "Updated Date", "Status"); while (packages.Any()) { foreach (var package in packages) { swFile.WriteLine("{0},{1},{2}", package["id"], package["updated"], package["status"]); } x += 50; y += 50; response = httpClient.GetAsync(new Uri(API_URL) + "/packages?from=" + x + "&to=" + y + "&lastUpdatedStartDate=" + dateFrom + "&lastUpdatedEndDate=" + dateTo + "&query=").Result; obj = JObject.Parse(response.Content.ReadAsStringAsync().Result); packages = obj["results"]; } swFile.Close();

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