Click here to Skip to main content
15,794,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have Restful Api Get Method, I am consuming this service and getting wast data but it has limit per each request

For each request I can get only 500 records, Now I want to get all the records from the rest service and need to save it in database

What I have tried:

I tried to get all the records from the service

 RestClient Client = new RestClient(URL);
var request = new RestRequest("items", Method.GET);
                request.AddParameter("api_key", SystemToken);
                request.AddParameter("StateName", StateDetails);
 IRestResponse<RootObject> response = Client.Execute<RootObject>(request);
return response.content;

Here In response I can see the count as 10000 records but for each request It displaying only first 500 records
Updated 28-Mar-19 14:10pm

1 solution

Read 500 ... then the NEXT 500 ... using a key greater than the LAST key (assuming they are in some order)
Share this answer
Divyay208 29-Mar-19 9:40am    
Key wont get change the same key I need to pass for all the requests, here I am getting count only so based on count how can i repeat the requests
Divyay208 29-Mar-19 10:24am    
int count = response.count;
int page_size = 10;
int loop = count /page_size;
for (int page = 1; page <= loop; page++)
RootObject restrequest= await ExecuteAsync<rootobject>(State, page_size,page);


In this way I am looping and sending requests but the max pages of rest api is 100 so I am getting first 1000 records only and each request(limit of api is 10) I am getting 10 records

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900