使用参数和令牌在C#中使用restful get方法 [英] Consume restful get method in C# with parameters and token
本文介绍了使用参数和令牌在C#中使用restful get方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有Restful Api Get Method,我正在使用此服务并获取数据,但每次请求都有限制
对于每个请求我只能得到500记录,现在我想从其余服务中获取所有记录,需要将其保存在数据库中
我尝试过的方法:
我试图从服务中获取所有记录
RestClient Client =新的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);
返回response.content;
这里作为回应我可以看到计数为10000条记录,但每条请求只显示前500条记录
解决方案
读取500 ...然后NEXT 500 ...使用大于最后一把钥匙的密钥(假设它们按某种顺序)
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
解决方案
Read 500 ... then the NEXT 500 ... using a key greater than the LAST key (assuming they are in some order)
这篇关于使用参数和令牌在C#中使用restful get方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文