1
votes

I am using .Net API provided by Podio. By default it fetches only 20 items per request. If we set filter limit to 500 (Which is max for podio) I can fetch items in sets of 500 for all items. But here I am facing issue how to iterate these items collection 0 to 500 501 to 1000 1001 to so on.... I am getting total count of items in podio Below is my Code

            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;
            }

This is fetching same items every time it iterates. Expected is after first 500 it should start from 501 to next 500 items... Can anyone help as there is very limited documentation on .Net podio API

2
Can you please share bit more details on how you define filterOption? Also, you don't need remember=true part, exactly opposite, if you are not going to re-use this filter call, then you should set remember=falsePavlo - Podio

2 Answers

1
votes

Please try something like this:

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);

and verify that items_1 and items_2 are actually different items.

Sources for FilterItems method are here: https://github.com/podio/podio-dotnet/blob/master/Source/Podio%20.NET/Services/ItemService.cs#L280

0
votes

If you are trying to get all items, this will do:

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);