首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用用于.Net的Podio获取所有Podio项集合

使用用于.Net的Podio获取所有Podio项集合
EN

Stack Overflow用户
提问于 2016-12-12 10:40:52
回答 2查看 363关注 0票数 1

我正在使用由.Net提供的Podio API。默认情况下,每个请求只获取20个项。如果我们设置过滤限制为500 (这是最大的podio),我可以在一组500的所有项目。但在这里,我面临的问题是如何迭代这些项目集合0到500 501到1000 1001到等等。下面是我的代码,我得到了所有项目的数字

代码语言:javascript
复制
            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的文档非常有限。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-12-13 01:57:15

请试试这样的东西:

代码语言:javascript
复制
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_1items_2实际上是不同的项目。

FilterItems方法的来源如下:https://github.com/podio/podio-dotnet/blob/master/Source/Podio%20.NET/Services/ItemService.cs#L280

票数 1
EN

Stack Overflow用户

发布于 2016-12-13 06:41:42

如果您正在尝试获取所有项目,则可以这样做:

代码语言:javascript
复制
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);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41098964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档