In the app I am working on, a company admin user signs up and pays for subscription for 1 seat. Then he adds 4 more users, and I need to update his susbscription from 1 seat to 5 seats. In order to do that I can update the subscription item to 5 seats. However, I have trouble getting the subscription items from the subscription API response.
The subscrption API returns a list of subscription items in a nested list, items:data[ ] as “Get a Subscription body data”. It is not available in WF steps because it is a list. So how I can access the list in a WF step?
You cant iterate on a list if its action type is action make it data and then on a you can schedule a workflow on that list and add the user for which you are creating a subscription id.
Not fully got setuation when i be on my system i be in better position to help
Oh, you are saying because the api call return a list you were not able to access it, its not possible you definitely be able to access it in referencing that step.
Name can be a little annoying but can reference it.
Referencing nested objects in an API response is definitely confusing in Bubble. In case it’s helpful, ...object quantity is the property I reference to get the number of seats in a subscription from Stripe’s Update subscription webhook.
A subscription is a collection of subscription items. In this case, I only have 1 subscription item. I need to get the subscription item ID in order to update subscription item’s quantity. So I call the subscription API which returns a list of subscription items. Because the list is a nested list, I don’t know how to access the list.
The nested elements will appear in the response if they are available. So if the elements are not there it may mean you need to make a different call.
So from a very generalistic pointing of view, I had an unexpected situation which may be similar. SO what I was doing was setting up subscriptions. And they could either be set up on the back on a full payment or on the back of deferred payment (intent).
What I learned was on the full payment the nested JOSN I was expecting to be there was, but when I used the same API for the deferred payment, the data wasn’t.
So I had to put in a conditional to make a slightly different call for the deferred payment through the intents API rather than the payment API to get the data I needed.
I suspect there is something similar going on there for you.
The data (subsription item list) exists. It is there when I initialize the API. It is the same subsctiption ID that I use in the app. The problem is that Bubble does not show a nested list in WF step. So the solution is to find out how to access a nested list in Bubble or find a different way to get the subscription items that is not in a nested list.
If you compare these two screenshots you will the raw API data in the call returned from the call to Stripe and then the data as shown in the editor. It returns the nested data as a list within the list.
Otherwise the other way to do it, is to make the call two part. You can call the nested elements directly with another API call if you know the ID to make that call rather than rely on it being nested.
also the other thing is, when you initialise the API, it is always (as in the your screen shot) for a very specific subscriptions ID.
That is the ideal scenario. Where as in practice, the data may not exist in your actual real life call to the same API with a live ID - for various reasons, but broadly speaking because the use case is not there.
What I do in situations like this is work through an example in postman, and make the call as you step through.
Or, the other way to debug is to set up a database table where you print the data to the table during the workflow (using it like a log file). Create a new row for each step in the work flow and you can see the real request/reponse data and you will soon see why data you are expecting is missing (I find this a much more efficient way to debug, bs the live debugger, which often skips ahead or behind of the real request and can be very tedious).
You need to see the real data going back and forth and then inspect it to see where the error is.
I use the same subscription ID in the API Connector and in the WF because I only have 1 subscription. But the issue is not the miss data. The problem is that I can’t get the subscription item list in the WF step to access the subscription item ID field to assign it to a DB field. On your screenshot, you can see each item’s id, etc. I don’t see those.