I'm still sort of new to .NET and .NET CORE, and think I need a nudge in the right direction on something...
My .NET Core web application needs to communicate with an external REST API and grab some data. Now, I can successfully authenticate and get back limited data. The problem is that I can't figure out how to grab ALL the data I need. I'm trying to access the ClearPass Policy Manager Configuration API and grab a list of all the devices in the system. But it seems to have a limit of 1,000 records. How do I go about paging or something in order to grab the 2,000+ entries from the API?
Here's an example of what I've currently got (limited to 999).
using (var httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(baseUrl); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken); //HttpResponseMessage response = await httpClient.GetAsync("api/device"); HttpResponseMessage response = await httpClient.GetAsync("api/device?filter=%7B%7D&sort=-id&offset=0&limit=999&calculate_count=false"); if (response.IsSuccessStatusCode) { //do my stuff } }
Thanks!