I'm using VS 2017 to rebuild a C# app. However I cannot retrieve more than 3993 records and I need to get ~180K to insert them in a flat table (SQL db)
I think the pagination method was not designed properly and I'm not pretty sure how to fix it, If I add a number greater than 4K it crashes. What could be the best method to fix this?
This is what we have so far:
Helper.cs:
{
ItemsDto itemsCollection = null;
HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
var uri = string.Format(@"{0}pageSize={1}&page=1", Constants.REQUEST_ENDPOINT, Constants.MAXVALUE);//Constants.MAXVALUE);
uri = uri + "&advancedFilter=__Status__~eq~'Active'";
uri = uri + @"&dynamicColumns=Name,ID,Date,Status,Version,Name,Division";
uri = uri + "&orderDirection=DESC";
HttpResponseMessage response = await httpClient.GetAsync(uri);
if (response == null)
{
throw new Exception("There is no returned request from API");
}
if (response.IsSuccessStatusCode)
{
var responseAsString = await response.Content.ReadAsStringAsync();
itemsCollection = JsonConvert.DeserializeObject<ItemsDto>(responseAsString) ?? new ItemsDto();
}
else
{
throw new Exception("An error request has ocurred: " + response.RequestMessage);
}
if (itemsCollection.Items == null)
{
log.Info("There is no files available");
itemsCollection.Items = new List<Document>();
}
return itemsCollection.Items;
}
App.config:
<add key="IntMaxValue" value="4000" /> //Change pageSize Here
Constants.cs:
public static readonly int MAXVALUE = int.Parse(ConfigurationManager.AppSettings["IntMaxValue"]);