Set Form Data to Json

Hi, I have a form data which needs to be converted to a json file.and send this file to the POST API. how can i create the json file from the form data and send it with the API?

the easiest way is to use “arbitrary text” and build the json with dynamic data

You can definately use arbitrary text. If you have a list of JSON objects or require nesting, you will want to use the “format as text” function on your list.

You can build a full JSON structure out with those two functions.

Connect with me:

Hi @ilanmichalby

Thank you for your response. Entering the json values in the arbitary text makes a lot of sense. but then how do i make it send like a json file to the API.

I am attaching a screenshot here. Pls advise.

Screenshot 2024-04-22 at 12.48.48 PM

@adam30 @ilanmichalby pls advise.

does it have to be as a .json file? Or just as a JSON body?

Do you have a link to the API documentation?

Hi, it has to be .json file. The API takes it in multipart format since there are a lot of fields in the form.

Here is the API:

curl --location ‘/school-admin/school/create’
–header 'Authorization:
–form ‘school_details=@“/Users/atullakhotia/Downloads/create_school.json”’
–form ‘school_image=@“/path/to/file”’

@adam30

Okay if you need a .json file, you will need to use a plugin to convert your arbitary text to an actual .json file

you could try: Download, Save and Create File Plugin | Bubble

When you create the filename, use the extension “yourfilename”.json to make sure it saves as a .json file

Let me know if that helps :slight_smile:

Connect with me:

Hi @adam30 : thanks for your response. I tried installing this plugin but could not access the plugin. also, i could not find any information on the support page also

@lakhotiaatul

I can access the demo page at: Bubble-essential-plugins | Bubble Editor

If you are still having trouble, I can create a video on it in the next few days if that is helpful

@adam30 : i was able to use the plugin and create a json file, save it to bubble database and link it to the API. Now trying to see if it works. will keep you posted.

Thank you so much.