External API Send Persisted Collection Data as Raw JSON
This video tutorial tells you how to send stored data from collection to the rest API while using an external API.
1. Create an External API
To get data from any third-party integration like Airtable you need to create an External API. External APIs are modules that are used to create a Rest API such as GET API, POST API, DELETE, etc. Although you may also use an existing API too.
APIs can be accessed from Settings → External API or from the top right hand-side. Then select the Create External API button. Give a name to your external API. You need to choose a call to create. Then copy the URL from the Airtable Documentation.
1.1 Request Data Mapping
Here you have to fetch the data from a persisted collection. For this choose Send Collection Data and the Collection from the dropdown. Specify the Authorization, Bearer and Token from the documentation. Then click Save Setting to finish the process.
1.2 Map the Collection Data
To map the data from collection mention the data key that has the records in it, specify what is the key to uniquely identify the records for eg., ID and mention the JSON path for other fields. Then choose Raw JSON.
You can copy the Records as it is from the documentation and paste them here. Add fields being fetched dynamically from the collection by clicking Show Fields. Then click Save Settings to finish the process.
2. Drop a Collection Form
Go to Pages Components and drop a Collection Form to create a structure for the collection. Open the Settings of the the Collection Form and specify where it should fetch the data from which collection and Save the changes.
3. Create an Event
You need to create an event to make the call to fetch data from form to Airtable or any third-party integration. Go to Events and choose Create Event. Name your event and click Create.
3.1 Configure the Event to Save Data
In the event mention what it is supposed to do. Here in this case it you can choose the collection to save data as the first event.
3.2 Add the Event Details
In the pop-up that opens select the collection in which you want to save data. Then you can mention an alert message and how you want to save it (this is optional). Then choose Save to finish. This will make the API call and store it in the collection.
3.3 Configure the Event to Send Data
In the event mention what it is supposed to do. Here in this case, you can choose the external API and ask it to send data to the external API i.e., Airtable.
3.4 Specify the Event Details
In the pop-up that opens select the external API you created. Then you can mention an alert message or how you want to save it. Then choose Save to finish. This will make the API call and store it in the collection.
4. Bind the Event
Open the Form settings and mention the event to which you want to bind it to. This will save the data then send the data to the external API which will send it to Airtable. Then Save your settings.
5. Create a Project
Go to Preview and add details as per the fields in the form. Then click the Submit button. This action will save the data in the collection and send it to Airtable or any other third-party integration and display the alert message for this action.
6. Preview the Data
You can go to the Rest API or the collection and reload it. Your form data will appear in the collection as well as Airtable. Similarly, you can add more records/ map more fields in Raw JSON and have them pushed to the Airtable while saving them in the collection.