Help! API Connector and Patching Nested JSON

Hi all,

I am hoping someone can tell me:
1.) If I am configuring the API Connector Call incorrectly OR
2.) Bubble can’t Patch to Nested Objects.
AND
That someone can find me a way to move forward!

I faced a similar problem for loading nested json into the database and @georgecollier saved my ass by coming up with a clever work around. Hoping that George or someone else will be able to come to my rescue on this occasion as well.

I am trying to update the Vimeo embed Parameters using the Vimeo API.
I have one Vimeo Patch working like a charm. See below.

I thought that this next one would be a cinch but had not realized that the fields are nested two or three layers deep.

{
“embed”: {
“buttons”: {
“watchlater”: true,
“share”: true,
“embed”: true,
“hd”: false,
“fullscreen”: true,
“scaling”: true,
“like”: true
}
}
}

When I put this into the API Body Window, it seems to want to recognize it but it fails. I am unable to change the name from true for the value key pair and the system doesn’t create entries for all the variables I have brackets for.

I want to do this in the API connector if at all possible so am hoping that someone out there has a way to make this work.

Xano may be my best alternative but I also want to keep things completely in Bubble.

Thanks in advance for your help.

Cheers,

KH

It’s possible. You put probably the value of each dynamic key instead of a placeholder. What did you put in value? Which error do you get?

So, am I able to do a Patch with JSON that has three layers of hierarchy?
How many layers of hierarchy can Bubble handle?

I am trying to replace “true” with “watchlater” in the case of the first field but it will not let me. There are boolean values so I don’t think they could have another field name.

Can Bubble handle three layer json hierachries?

thanks.

KH

All people listening - is this issue as relevant as you?

by that I mean is the AI that is foldering clothes in Disney is an intersting company.

You’ve name two variables in the payload: true and false and it has declared them for you below. Which are you not seeing?

Looking at your Vimeo example above you’ve used the key names as the names for the dynamic variables. In this example you seem to be using the values. What’s the reason for that?

Hi @exception-rambler ,

Thanks for your help.

I may have misused the word variable in this case.

What I should have said was that the system is not creating entries for all seven key value pairs that appear in the JSON Body. (eg “watchlater”: ,…). The system only creates two entries in total.

I have not changed the names of the dynamic variables because the system will not let me change them. If you look at the image of the vimeo embed API call that is working, I was able to change the names.

Which leads me back to my primary question.
Can Bubble’s API Connector handle the level of JSON object nesting that I have shown in the second image?

thanks
KH

Hi @ Jici,
Thanks for the question. Forgot to tag you in my response last night.
You said.

By that do you mean that it is in fact possible to use nested JSON in the JSON body of a Bubble API Connector Patch call?

The call that is working is only is two brackets deep. The one that does not work is three brackets deep and I have additional key value pairs that would make it four curly brackets deep.

your dynamic variables shouldn’t be
{
Name: < true >
}

They should be
{
Name: < name >
}

Then in the actual value goes in the param box below the JSON box now.

@chris.williamson1996
Thanks!! You are absolutely right. Every other time I had done one of these the values have been unique so I remembered the process better. My concerns about whether Bubble could handle nested object did not help. I remembered changing the names of the variables in the key value pair box instead of the JSON Body Window. Doh!!!

========================
To those who get confused by the same thing I did, I am attaching an image of the right way to do things that Chris has outlined above.

The key value pair input boxes are created when you put “<” and “>” on either side of the value entry in the JSON Body. I was trying to change the name of the key in the box that was created - while what I needed to do was change the name inside the brackets (“<”, “>”).

When the box is first created - it puts the name of the value that was in the JSON file you are using. What should have been my clue to my mistake was that it would only create two key value pair entries. The reason being that you cannot have two identical keys (field names). As all my values were boolean (ie true or false), the system was only able to create two entries one for true and the other for false.

@Jici @exception-rambler and @chris.williamson1996 all spotted my error and Chris was finally able to make me see it. Thanks to all.

1 Like