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

ListAutoPaging doesn't work with EndingBefore if there is more than one page #1848

Closed
sandfield-andy opened this issue Nov 25, 2019 · 3 comments
Labels

Comments

@sandfield-andy
Copy link

I was trying to use the auto pagination functionality to pull all balance transactions after a specific transaction by making use of the EndingBefore property in the list options.

Retrieving the first page works fine but if there is more than one page it seems ListAutoPaging sets the StartingAfter property in the options object I've passed through which then throws an exception stating the following:

Received both starting_after and ending_before parameters. Please pass in only one.

I would either expect it to prevent you from passsing ending_before to begin with or handle it.

Here's an example of the code:

BalanceTransactionService service = new BalanceTransactionService();
RequestOptions requestOptions = new RequestOptions
{
	StripeAccount = _stripeAccountID
};
BalanceTransactionListOptions balanceOptions = new BalanceTransactionListOptions
{
	EndingBefore = _lastStripeTransactionID,
	Limit = 100 // This is the maximum allowed.
};

// service.ListAutoPaging results in >100 transactions
foreach (BalanceTransaction transaction in service.ListAutoPaging(balanceOptions, requestOptions))
{
	// Process transaction
}

Let me know if you need any further information.

@remi-stripe
Copy link
Contributor

@sandfield-andy At the moment we don't support auto-pagination with ending_before which is why you're hitting this error. For now, the easiest is to paginate as usual (from the most recent objects first) and stop once you see the id you were looking for.

I'm going to tag as future since this is something we want to add support for in the future.

@remi-stripe
Copy link
Contributor

@sandfield-andy We just release a fix in 33.8.0 that supports this!

@sandfield-andy
Copy link
Author

Awesome, thanks @remi-stripe!

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

2 participants