API On List not Writing to Database

Hopefully my last post on here for a while. I have been wrestling with this API from a list for 4 weeks and it went from writing the cart items 6 times each when there were 6 items, to not a tall, to having blank records. And yesterday I forgot my iteration and it posted 15000 in before I stopped it (heh heh ).

Our app receives data from Shopify in the form of JSON and one of the elements is a list called items which is essentially the items in a cart you are buying from the Shopify store (see JSON sample). I am capturing 7 elements on the items (see image) and using an API Workflow on a List of Request Data Items that calls the API Endpoint cart-items-processing that accepts the data and a value called iteration that starts at 1.

Once the cart item is written to the table (using item #iteration), an API workflow calls cart-items-processing and updates the iteration value with a plus one and it runs only if the iteration is < count of the productids in the items list.

The API Workflow runs in the background (see image) but nothing is being written to the database. Been staring at this now for a few weeks so many some fresh eyes can spot an error.

Our app allows consumers to make offers to buy their Shopping Carts from a merchant using the Shopify platform, We use Bubble to process the offers based on settings the merchant establishes on what they will and will not accept and then we inject a discount code to the cart when the offer is accepted and return the response to Shopify. The cart-items-processing allows merchants to see what items were in the offers and we allocate discounts across them so this piece is kind of important.






In your Schedule on a list, you doesn’t seem to use the correct settings for fields.
For example, productId should be “This request data item’s productID”
Also, I don’t think that the API workflow should have “list” enabled
Finally, you don’t need to use iteration# in a Schedule on a list…

You could explore using your Bubble apps API to create in bulk. It requires JSON formatting, so might just take Shopify response and send into your Bubble App API call to bulk create

the workflow cart-offer-evaluation recieves the JSON payload and is a public endpoint for the data. Are you saying the action should be schedule API Workflow cart-items-processing and not Schedule API Workflow on a List cart-items-processing?

The second image is the API workflow on a list and it takes the request data in and passes it to cart-items-processing that receives the data and then passes it to create-cart-items and then the next step is schedule API workflow. Are you saying it’s backwards?

cart-offer-valuation → schedule api workflow on a list → cart-items-processing → create cart items → schedule api workflow → cart-items-processing

Are you saying the schedule api workflow on a list should be the end of the loop that sends it back to cart-items-processing? Not sure I am following you.

Sometimes it’s only one product being purchase so a product id , variant id, etc… not much to bulk create there. I also scheduled the cart-items wokflow to run after the decision is made so as not to get in the way of sending the response back to the customer on shopify

Doesn’t matter if it is one or many the approach is the same, so if sometimes it is many, you may want to investigate using the Bubble App API to bulk create and just send in the Spotify JSON

I’m talking about the cart item processing workflow. Everything in that should not be a list and your schedule api workflow on a list, that schedule this API workflow (cart item processing) should be modified to use “this request data item…”



Still not creating the records -

Schedule Api Workflow On List → cart-item-processing → create cart-items → schedule API workflow → cart-item-processing

I could have written this in SQL in 10 minutes. #smh

Any privacy rules? Also, What logs show you when you schedule on a list? Are items scheduled or not? Contain data? You can pause and check scheduler and resume after

There are no privacy rules on the backend workflow because it does not touch a user or can be accessed by a user.

The server logs read Running Action
Finish Action and have the right record count for the latest cart (it sucks, I have to create a cart every time I test this - I’m close to 400 LOL).

It does not show the record(s) that are written

I can see in the JSON load in the console that the items are being sent from Shopify. Maybe I should just write them to a text field to make sure they are captured. I might try that.

The data is a JSON Array - this test only has 1 item

Found it - not a privacy rule = Bubble was looking at logs not working (it the initial condition fails no log, even initiating the workflow, is recorded. During that time, the cart-items-processing workflow was paused. Would be nice to have an alert - but hey - I found it after a week .

1 Like