Process for Creating Multiple TYPES of related Things from a nested JSON response

Hey, all! I’ve spent quite a bit of time reading through the forums to find an answer to this, but please feel free to point me to an existing thread if I’ve overlooked anything.

Core Question:
Am I able to use Bubble’s bulk data api to create not only multiple things, but multiple TYPES of things (i.e. multiple data tables), and define their parent/child relationships? Or do I need to focus on triggering a backend workflows to manage this?

Use Case:
I’m using an external API to parse a resume. API call is successfully set up and I am able to successfully receive a JSON response, which contains multiple tiers of nested data that correlate to multiple “types” of related things in my database.

Data Structure:
Note: I’m over-simplifying for illustrative purposes.

As per best practices to support one-to-many relationships, the data structure consists of multiple related things of different types. For instance, Skill2 below maps to multiple Jobs under a particular User account. Likewise, the JSON nests a Skill object under both Job1 and Job2, as one would expect.

JSON snippit
(sorry the formatting is probably pretty crummy )

<header, other JSON metadata, etc.>
“user”: {“first_name”: “John”,
“last_name”: “Doe”,},
“Experience”: [
{“title”: “Some Title”,
“description”: “Some description.” },
“skills”: [
{“name”: “public speaking”
“type”: “softskill”},
Etc…

(@jacobgershkovich)has put out an incredibly helpful video about the creation of multiple things of the SAME type using the Bubble bulk API, and a simple JSON response, which I’m comfortable with at this point. But I’m stuck on whether the Bubble bulk API functionality can be extended as described above.

Anyone have any advice?

Do multiple Bulk Create actions, one for each datatype you would like.

No issues defining parent/child relationships?

Since it’s not a workflow (there’s no “results from stepX” to reference) How would I go about defining the relationship between each appropriate created “thing” from the first Bulk Create call with things created in the second (and third, etc.) call.

Example:
Bulk Create 1: Creates 5 “Job” Things (JobThing1 … JobThing5)
Bulk Create 2: Creates 20 “Skill” Things (SkillThing1 … SkillThing20)

SkillThing1 and SkillThing5 have a reference to JobThing1
SkillThing1, SkillThing2, SkillThing5, SkillThing12 reference JobThing2, etc)

I understand how to create these references (relationships) in the database, and when using workflows; I guess it’s not clear to me yet how this is done using the Bulk Create api.

Sorry if I’m just missing something super obvious! I’m definitely still a bubble rookie :slight_smile:

Thanks in advance for your willingness to help!

So if your datatype Skill has a field for Job (type is Job), then when you go to bulk create Skills, you provide the Job unique id for the Job field and Bubble will make that relationship.

It get’s a little bit more tricky if you need to go the other way, like adding the newly-created Skills to a list field on Job, then that will take some more work but can be done.

And sounds like your situation has quit a bit of layers/dynamic aspect to it so this might take some work :muscle:

1 Like

Although you will need to extract the resulting unique IDs from the first Bulk Create so you can use them in the 2nd Bulk Create anyways, that will need some text find& replace-trickery unless someone has a better way

{"status":"success","id":"1671702337369x488321592367327900"}
{"status":"success","id":"1671702337369x488321592367327901"}

This would be the result when creating two things

I bet you could do nested Bulk Creates by setting them up as Data instead of Action… :thinking:

1 Like

Oh interesting idea, thank you for your help! I’ll play around with this a bit this afternoon and see if I can get any traction. Worst case, I go back to using a workflow to drive this behavior… just wanted to see if I could get something working that might be little faster, thus exploring the bulk approach.
Dan

Hi, I am really stuck at making this work through a workflow. Could you explain how you make it work? Thanks!

Hey @petarmx5
I ended up rethinking my approach to how I wanted to organize my data and went a different direction that didn’t require such a complex structure, and could more easily be managed via some backend workflows & db triggers. I don’t recall the full details offhand (and they’d be really specific to my use case anyway, I think). That being said, if you want to share what you’re trying to accomplish in more detail, I’d be happy to try to help.

Thanks for the reply @danschlung , I managed to resolve my issue. I went with the bulk create solution. Basically, I bulk created a thing separately for every nested response and managed to extract the unique IDs of every bulk create, to connect all the stuff together. Pretty much how @tylerboodman explained it. Thanks!

1 Like

Bulk create API :muscle:

@tylerboodman I just ran into a new problem. Once I bulk create things the creator field is empty. Do you know how to change the creator field to the current user?