API Call to Load Data - HELP!

Hi Everyone, I am trying to load data from an API endpoint into Bubble, and I’m stuck. I have read the manuals, forum posts, watched videos and it all makes it seem simple, but its not.

It is a very simple API, it does not require authentication, it is just an endpoint that contains structured JSON data. However I cannot figure out how to take that endpoint and setup a scheduled import that will write the JSON data into the Bubble Database.

It is driving me nuts. I could have written this in Java in a couple hours, but Bubble is making it much harder.

Can someone walk through step by step how to setup the workflow to write to the Database via an API?

Let me know .

Thanks
Jon

Why do you want to write the json into Bubble when you can call it live when you need it?

1 Like

The API Response is JSON. That’s all I mean.

That JSON response needs to be parsed and written into the Database, however I am unsure how to do that with the Bubble API Builder and Workflow Builder, and the Manual doesn’t explain that workflow.

The Bubble Manual gives an example of pulling from an iTunes API to populate a Repeating Group, NOT how to write to the Database and I am unable to figure it out.

Here is exactly what I need to do:

STEP 1) Connect Bubble to Import.io via Bubble API Builder

  • Use an Unauthenticated Call (DONE)
  • Add a GET Call to Import.io API Endpoint (DONE)
  • Use JSON as the Response Data Type (DONE)
  • Use as “ACTION” or “DATA” (?? Not sure )
  • Initialize Call (DONE)

//STEP 1 is done and working. I can see the Response Structure come through with 15 Text Fields I want to write.

STEP 2) Create a Workflow to write to the Database (THIS IS WHERE IM STUCK)

  • Parse the API Response to match to the Bubble Database “Thing” (how?? where?)
  • Iterate through the entire Response to write ALL Records in the Response to Database (HOW??)
  • Schedule this Action to repeat every 24 hours (HOW?)

//HOW DO I DO STEP 2?

Do you know how to do that Jlcl?

But the question is Why you want to store it in DB? You can just call it in frontend instead?
If you want to store it, Create a Data field of the Type of the API Call (after the standard type like text, after the DB type like user, you will find the API type listed).
You should not have to parse the API response because it’s already parsed.
If you want to iterate into a list in the response, you need toSchedule API workflow on a list. This will take a lot of Server ressource (this is why I’m asking why you want to store data).
You can Schedule API Workflow to store the whole payload into a Field and reschedule 24 hours later

The issue turned out to be a bug.

When I created the API it wasn’t showing up on the Workflow Screen, so this prevented me from doing any further mapping to create a Data Thing.

Finally I thought to just create a new API and then it showed up. Go figure. Sometimes you just have to bash at a system or start over to get it to behave properly.

As for my question then, the answer is:

STEP 1
Create a new API
Unauthorized
GET call with JSON type data
Enter the API Endpoint
Initialize API (check that it works, you should see the structure of your API response)

STEP 2
In Workflow

Create a New Event (any event you want)
Create Action
Create new Thing > Select Table you want to write Data to.
(in my case its a table called Job)

THIS IS KEY
for each field in your Table, you need to define the source.
Choose External API > then choose your NEW API that you created (this wasn’t showing before, so if you don’t see your API, delete the old one and start over… this is a bug)

Then for each Field, you need to map it to the API… your API may have a nested structure, so for example my API I needed to select

API > Data > Group > Link URL > :first item > text

Data - because this is the block that contains the payload
Group - because the payload is structured for possible repeating items
Link URL - this is the actual bit of data I was looking for (but not done yet!)
:first item - is a directive to take the first item in the group list. Since there was only one item its not a problem
text - is the data type that I defined in the API Builder to match my Job Table.
Data types must match.

This was not at all clear or easy and required significant experimentation. The Manual use case (and forum posters) only tell you how to post the data to a Page for on demand use, however my use case required us to store the data in a table so we could further analyze it and use it for future transactions.

Writing data from an API to a Database should be pretty straight forward and it can be once you have the API response AND are able to properly see the API Response is available on the Workflow Screen.

Good luck anyone else attempting this use case.

If you don’t see your call in Workflow action like it should, it’s probably for two reasons:
A) You didn’t set the API Call to use as “ACTION”
B) The call is not initialized correctly.

If you don’t see your call in Get data from API, there’s two reasons:
A) You didn’t set the API Call to use as “DATA”
B) The call is not initialized correctly.

So I’m pretty sure that the issue you faced was probably related to this. If not, you should send a support ticket. I personnaly never face this issue. (But some other bugs :P)

@jon.mcgowan Hi Jon, almost a year later, but kind of in the same boat. Just wondering how you are iterating the workflow if there is more than one item to store to the database?

@bryan_333

A JSON array is used for this using :format as text so that you can build and pass it

min 21:48

1 Like