External API Sending Data as Custom JSON
This video tutorial talks about external APIs that integrate rest API with DrapCode. Using which you can send data to an external datasource by making simple calls.
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 which we are using in this example as it has great support of modules to make calls easily.
1.1 Request Data Mapping
Here you have to 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 Custom JSON.
You can copy the Records array as it is from the documentation and paste them here. You can even customize the records here as you want them to be sent. Then click Save Settings to finish the process.
2. Create an Event
You need to create an event to make the call to fetch data from the collection to Airtable or any third-party integration. Go to Events and choose Create Event. Name your event and click Create.
2.1 Configure the Event to Send Data
In the event mention what it is supposed to do. Here in this case it you can choose the external API and ask it to send data to the external API i.e., Airtable in this case.
2.2 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. Then choose Save to finish. This will make the API call and store it in the collection.
3. Bind the Event to Button
Open the Button settings and mention the event to which you want to bind it to. This will only send the data to the external API which will send it to Airtable. Then Save your settings.
4. Preview the Data
Go to Preview and click the button. This will send make a POST call to Airtable to create records. You can go to the Rest API or the collection and reload it. Your data will appear in the Airtable. Similarly, you can add more records/map more fields in Custom JSON and have them pushed to the Airtable.