Forum Academy Marketplace Showcase Pricing Features

How do I save a chunk of JSON data from an API?

I’m calling an API to get astrological data.

I want to save all the data in the “Planets” section, and nothing else. when I try do choose Planets, however, after the api call, it wants me to choose data nested within planets.

Screen Shot 2023-02-02 at 12.23.44 PM

I don’t want to save ultimate pairs because when I use the data, I want to use that whole “section” of json which means I have to re-compose the entire data set.

Is there a way to save the “Planets” section as a whole?

It looks like planets is an array, so if you want to save it in a single field you need to use a list field in the database.

1 Like

Thank you. I tried to set that up but can’t get the data to save in that field. What other setting should I be thinking about?

Screen Shot 2023-02-02 at 1.24.57 PM

add is for single items. You need to set the list. The value should be result of step1's planets

Thanks so much for sticking with me. The system, however, will not let me just use planets. It wants more detail.
Screen Shot 2023-02-02 at 3.39.50 PM

I’ve also tried playing with the settings in the api call where I have these both checked and unchecked.
Screen Shot 2023-02-02 at 3.50.09 PM

And, I’ve tried to try different text functions like “each item’s raw body text”.
Screen Shot 2023-02-02 at 3.49.39 PM

And the best I get is a list of “”:
Screen Shot 2023-02-02 at 3.49.15 PM

that’s probably because you need to set the field in the database to the right data type (the data type of the items inside planets).
If you put the expression that stops at planets and hover the mouse on it you should see what type it is (something like “evaluates to type”).

I feel like an idiot, but I cannot get this to work.

I created a new datatype:

Based on what the data is evaluating to:
Screen Shot 2023-02-02 at 5.46.06 PM

And I cannot get this data saved to the database. For now I’m going to save the whole thing in one text field and use find-replace to get at what I want. I’d love to figure this out, however, so if you have the patience, I’ll work on it. Thanks in advance.

if you want to save planets you need to look at the data type of one item in the planets list, not the type of the request and not the raw body test. You also should be able to see what is the type when you initialize the call with the api connector

There are a couple of different data types within the “planets”.

but I tried it using the “Birth Chart Call - Full JSON body planet” in the database.

Screen Shot 2023-02-02 at 6.22.16 PM

But, I got “data from API connector” in the database.
data from api connector

what type is plants_json_api_type?

It’s hard to see, but it’s in one of the screenshots. Its type “List of Birth Chart Call - Full JSON body planets”

Ok, it think you saved the list correctly.
The only thing is that the items of the list are not a “native” bubble data type so the database view of the editor does not know how to display them.
The data is there anyway and you should be able to use it and display it in the app.

interesting. I’ll have a look and let you know.

OK. Thank you very much for your help. I’m now getting what I want and I sort of used what you were suggesting.

First, I set up the JSON pairs in each of the planets:

Then roll up all the text into a single field using a backend workflow:
Screen Shot 2023-02-06 at 10.38.35 AM

If you’ve got a better way, I’d love to hear it.