#mikebm - expanding object
1 messages ยท Page 1 of 1 (latest)
Hi ๐
Yeah I ran into this recently while trying to solve someone else's problem. It's a max expansion depth problem.
Yep
Unfortunately this meant I had to separate my approach into two API calls. One to expand down to the price object.
Then using the associated product_id field to retrieve the product.
Yeah, this is what I was afraid of. Darn
Well hold on
Do you have a request ID that triggered the error?
I want to double check
I know I had a request that resulted in max expansion depth on another query for this same issue.
This one right now is resulting in this
com.stripe.exception.InvalidRequestException: This property cannot be expanded (data.subscription.price).; request-id: req_COcyGZXPsiM75h
Okay...yeah in this case you should be good to just exclude the data. portion for subscriptions.price.product
com.stripe.exception.InvalidRequestException: This property cannot be expanded (subscription). You may want to try expanding 'data.subscription' instead.; request-id: req_3XKkCigiEROzl0
oh oops, one sec
Same exception -
com.stripe.exception.InvalidRequestException: This property cannot be expanded (subscriptions). You may want to try expanding 'data.subscriptions' instead.; request-id: req_ouGKmxU7Wn1vjd
You could go from invoice.lines.data->expand price -> expand product
Well, basically, I want invoice lines yes
however, i think that is when I hit the max expansion limit
Hold on, I'm going to test this myself
Alright, I used Python so the syntax may be a bit off but
stripe.Invoice.retrieve('in_1K7qghIlCeH6bP8RRGEKswRj', expand=['lines.data.price.product',])
worked for me
Trying... I think one of the challenges is I never know when data is needed, or something else.
There's no shame in living in these docs: https://stripe.com/docs/api/invoices/object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I honestly can't go a day without referencing them
That's where I found the lines.data attribute and then followed that to the description of the line_item object
Yeah, I am technically using Invoice.list right now so let me try with that structure. One sec
And there it is
com.stripe.exception.InvalidRequestException: You cannot expand more than 4 levels of a property; request-id: req_Hp4Sa0U4po7Lqg
Need me a table flip emoji hah
InvoiceListParams params =
InvoiceListParams.builder()
.setCustomer(usc.getStripe_customerID())
.setStatus(Status.PAID)
.setLimit(100L)
.addExpand("data.charge")
.addExpand("data.subscription")
.addExpand("data.lines.data.price.product")
.build();
// .addExpand("data.lines.data.plan")
InvoiceCollection ic = Invoice.list(params, RequestOptions.builder().build());
okay, looking at this request
This is for an order history screen
In your third expand parameter
Yes, the 100 limit sucks. Need to implement some pagination soon.
We don't have a lot of orders right now
per customer
you don't need the first data
I do though, it gave an exception if i didn't use it
so this "data.lines.data.price.product" becomes lines.data.price.product
said I needed data.lines
OH...wait...
this is a list, right.
So because this is a list, it bumps the expansion past our limit of 4 levels. Sorry i didn't catch that earlier
yeah, no problem. I didn't really mention it until recently. My bad
In that case my best advice would be the 2 request approach and cache your results.
Especially since it's order history you shouldn't need to get this data more than once.
yep. That was the path I was heading down already, I just didn't want to if i could avoid it. Thank you though.
I already will most likely have these in cache anyways since we cache product with all our sku and price fetches
Yeah, the overhead and complexity struggles are real.
Well, awesome, appreciate the help! ๐
Any time ๐