User Profile
Violet_GA
Frequent Visitor
Joined 3 years ago
User Widgets
Contributions
Re: List.Generate cursor pagination using created.gte Stripe parameter
I have altered the function a bit, though there is an error there is a list with 100 records displayed in power query. The problem is that this function doesn't loop to provide more lists with limit of 100 records, do anyone have an idea why? let StripeData = List.Generate ( () => [StripeRecords = Json.Document(Web.Contents("https://api.stripe.com/v1/charges?limit=100")), MoreData=StripeRecords[has_more], starting_after= StripeRecords[data]{List.Count([StripeRecords][data]) - 1}[id]], each [MoreData]=true, each [StripeRecords = Json.Document(Web.Contents("https://api.stripe.com/v1/charges?limit=100&starting_after =" & starting_after)), MoreData = [StripeRecords][has_more], starting_after = StripeRecords[data]{List.Count([StripeRecords][data]) - 1}[id]], each [StripeRecords] ), StripeData1 = StripeData{0}, data = StripeData1[data], #"Converted to Table" = Table.FromList(data, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"id", "object", "amount", "amount_captured", "amount_refunded", "application", "application_fee", "application_fee_amount", "balance_transaction", "billing_details", "calculated_statement_descriptor", "captured", "created", "currency", "customer", "description", "destination", "dispute", "disputed", "failure_balance_transaction", "failure_code", "failure_message", "fraud_details", "invoice", "livemode", "metadata", "on_behalf_of", "order", "outcome", "paid", "payment_intent", "payment_method", "payment_method_details", "receipt_email", "receipt_number", "receipt_url", "refunded", "refunds", "review", "shipping", "source", "source_transfer", "statement_descriptor", "statement_descriptor_suffix", "status", "transfer_data", "transfer_group"}, {"Column1.id", "Column1.object", "Column1.amount", "Column1.amount_captured", "Column1.amount_refunded", "Column1.application", "Column1.application_fee", "Column1.application_fee_amount", "Column1.balance_transaction", "Column1.billing_details", "Column1.calculated_statement_descriptor", "Column1.captured", "Column1.created", "Column1.currency", "Column1.customer", "Column1.description", "Column1.destination", "Column1.dispute", "Column1.disputed", "Column1.failure_balance_transaction", "Column1.failure_code", "Column1.failure_message", "Column1.fraud_details", "Column1.invoice", "Column1.livemode", "Column1.metadata", "Column1.on_behalf_of", "Column1.order", "Column1.outcome", "Column1.paid", "Column1.payment_intent", "Column1.payment_method", "Column1.payment_method_details", "Column1.receipt_email", "Column1.receipt_number", "Column1.receipt_url", "Column1.refunded", "Column1.refunds", "Column1.review", "Column1.shipping", "Column1.source", "Column1.source_transfer", "Column1.statement_descriptor", "Column1.statement_descriptor_suffix", "Column1.status", "Column1.transfer_data", "Column1.transfer_group"}) in #"Expanded Column1"1.8KViews0likes0CommentsList.Generate cursor pagination using created.gte Stripe parameter
Hi All, I am trying to fetch charges records from Stripe API using their coursor paginator parameter created.gte, which would source all charges after or on certain created date. For this I am using this simplified structure of List.Generate function in power query let UTCTime= [APIData][data][created]/(60*60*24), StripeData = List.Generate ( () => [StripeRecords = Json.Document(Web.Contents("https://api.stripe.com/v1/charges?limit=100&created.gte=" & Date.ToText("2023-05-01"))), MoreData=StripeRecords[has_more]], each [MoreData]=true, each [StripeRecords = Json.Document(Web.Contents("https://api.stripe.com/v1/charges?limit=100&created.gte=" & Date.ToText(List.Last([StripeRecords][data])[created], ("1/1/1970")+UTCTime))), MoreData = [APIData][has_more]], each [StripeRecords] ) in StripeData but I am getting the following error: "An error occurred in the ‘charges’ query. DataSource.Error: Web.Contents failed to get contents from 'https://api.stripe.com/v1/charges?limit=100&created.gte=2023-05-01' (400): Bad Request Details: DataSourceKind=Web DataSourcePath=https://api.stripe.com/v1/charges Url=https://api.stripe.com/v1/charges?limit=100&created.gte=2023-05-01" does anyone know why and how to overcome it? thank you, Violet1.8KViews0likes3CommentsRe: Need Help with Stripe REST API Pagination in Power Query/M
Hi Phil PhilipTreacy I am trying to modify your code to use created.gt instead of starting_after parameter in order to fetch Stripe data created after 01.01.2023 (Timestamp1672531200). So far I manageed to get only the records within the provided limit but the result says has_more is True. Are you able to assist with some guidelines how to list generate from stripe api all charges created after 01.01.2023? thank you, Violet11KViews0likes0Comments
Data Privacy
Microsoft Fabric Community and Privacy
To learn more about how we manage your data, please review the Microsoft Fabric Community Data Privacy guide.