Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New List Filter Pagination Fields Has Encoded Fields Which Results in Empty Results for page 2+ #471

Closed
Powellze opened this issue Mar 4, 2020 · 2 comments
Labels

Comments

@Powellze
Copy link

Powellze commented Mar 4, 2020

@nozzlegear
Latest release V5.0.3
When using fields on the filter, the nextPageFilter encodes ',' as %2C, this results in the next page results pulling through with no fields selected.

For now i'm having to use your first code snippet of usage rather than the new suggested approach.
// bug with fields being encoded by shopify
newFilter.Fields = newFilter.Fields.Replace("%2C", ",");

See encoding issue:
image

See code i've used which works in production right now based upon your first iteration of recommended usage:
`
var hasNextPageResults = true;
var page = 1;

        while (hasNextPageResults)
        {
            ListResult<Order> result = await service.ListAsync(listFilter);

            Console.WriteLine($"Received page {page}");
            if (result.LinkHeader?.NextLink != null)
            {
                var newFilter = result.LinkHeader.NextLink.GetFollowingPageFilter();
                // NOTE: For now, you must set the limit and fields property for further page filters manually.
                newFilter.Limit = filter.Limit;
                // Set the filter to the following page filter, which will grab the next page.
                // Failure to do this will result in an infinite loop as the Shopify API returns the first page over and over

                // bug with fields being encoded by shopify
                newFilter.Fields = newFilter.Fields.Replace("%2C", ",");

                listFilter = newFilter;
            }
            else
            {
                hasNextPageResults = false;
            }

            items.AddRange(result.Items);

            if (items.Count > maxOrdersToReturn)
                hasNextPageResults = false;
            page++;

        }`
@clement911
Copy link
Collaborator

See #470

@nozzlegear
Copy link
Owner

Merged #470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants