我正在使用由.Net提供的Podio API。默认情况下,每个请求只获取20个项。如果我们设置过滤限制为500 (这是最大的podio),我可以在一组500的所有项目。但在这里,我面临的问题是如何迭代这些项目集合0到500 501到1000 1001到等等。下面是我的代码,我得到了所有项目的数字
int totalItemCount = 1750; //For this example
int totIterations = totalItemCount / 500;
int offsetValue = 0;
for (int i = 0; i < totIterations + 1; i++)
{
filterOption.Limit = 500;
filterOption.Offset = offsetValue;
filterOption.Remember = true;
filteredContent = await _Podio.ItemService.FilterItems(appId, filterOption);
//Some Code here
offsetValue += 500;
}这是每次迭代时都会获取相同的项。预计在前500项之后应该从501开始到下500项.谁能帮上忙,因为关于.Net podio API的文档非常有限。
发布于 2016-12-13 01:57:15
请试试这样的东西:
int limit = 1;
int offset = 500;
var items_1 = client.ItemService.FilterItems(appId, limit, offset);
var items_2 = client.ItemService.FilterItems(appId, limit, offset + 1);并验证items_1和items_2实际上是不同的项目。
FilterItems方法的来源如下:https://github.com/podio/podio-dotnet/blob/master/Source/Podio%20.NET/Services/ItemService.cs#L280
发布于 2016-12-13 06:41:42
如果您正在尝试获取所有项目,则可以这样做:
int limit = 500;
int offset = 0;
bool continueOperation = true;
var allItems = new List<Item>();
do{
PodioCollection<Item> filteredItems = await _podioClient.ItemService.FilterItems(appId, limit, offset);
offset = offset + limit;
allItems.AddRange(filteredItems.Items);
if (filteredItems == null || filteredItems.Filtered <= offset)
{
continueOperation = false;
}
} while (continueOperation);https://stackoverflow.com/questions/41098964
复制相似问题