Temporary store content from API

Hi everyone,

I’m struggling getting the responses of the API call I make. It’s been two days I’ve been on it and I cannot find a way to make it work properly… Here’s the use case.

  • I need the user to choose between 5 products and to select the options he wants (between option A and B). The final amount will not be the same depending on product & options. It’s basically sums.
  • I cannot change the body structure of the answer I get. Here’s what it looks like:

product1 {
“name”: productnameA
“statusCode”: x
“statusMessage”: x
“beans”: [
{
“code”: A
“label”: A
“amount”: 1
“amount2”: 1
},
{
“code”: optionA
“label”: A
“amount”: 1
“amount2”: 1
},
{
“code”: optionB
“label”: B
“amount”: 1
“amount2”: 1
},
],
product2 {
“name”: productnameB
“statusCode”: x
“statusMessage”: x
“beans”: [
{
“code”: priceA
“label”: A
“amount”: 1
“amount2”: 1
},
{
“code”: optionA
“label”: A
“amount”: 1
“amount2”: 1
},
{
“code”: optionB
“label”: B
“amount”: 1
“amount2”: 1
},
],
-> this is what I get from Postman’s body response

How can do that the simpler way?
I’ve thought of two different possibilities:

  • The first one is making 20 calls (because in total there are 20 different possible prices), each call will have different variables. The thing is: how bad is it for the performance? Plus it’s not maintainable if more options or more products will be available in the future…
  • The second one is to make only 1 call and to store temporary all the data (all the products, all the flat prices & the options), to make like custom states depending of the options the user choose front end and it will sum the amounts together.
    For that, I’ve tried it both ways: ACTION and DATA.
    —With Action, I tried to create a new Thing and to store all the data in it, but the thing is that all the products are stored in the same thing, instead of being in 5 (I have 5 products) -> Is there a way to parse it so it can be on 5 different records/things?
    —With Data, I cannot know how to simply get in ONE call all the responses. It seems to be 1 call = 1 specefic response (like the price of 1 option)

Thank you very much

When you use DATA type in api, this will create a type like if you have a different DB in Bubble. You can just use this to manipulate data the same way you would have manipulate them with Bubble Things.

I succeeded in writing new things into the Database (with type of API) but my problem is that I have an array of 5 objects and it writes all the 5 objects in the same row, I cannot figure how to parse the information.

Hey @tools4 since you are using postman, thought this might be useful.

It sounds like the is some issue on sending data via postman or you may need to some ETL massaging before sending data. How are you planning to post data to Bubble?

Here is a video I recently did to solve something similar: https://www.youtube.com/watch?v=LZp6tyD-1QA&t=1s

In above video, you will see the bulk data creation of multiple things. It sounds like you are able to handle it thereafter through your Bubble workflows.

I’d be willing to engage for a short project if you need more help.

Thanks!

email: santosh@n0c0de.com
twitter: https://twitter.com/n0c0de1
web: https://www.n0c0de.com (with two zeroes :wink: )

If you want to dynamically call the API, you don’t need to store anything into the DB.
You just need to select the correct list of thing. Please post some screenshot of your settings. This will be easier to help you.