How to Update Post Data Using API: Google Sheets Example
This article shows an example of how a Google Spreadsheet can be used to update post data on a site using the site's API.
Checklist Before Moving Forward With This Example
1) Make sure to generate a unique API Key using the documentation down below as a guideline. Please make sure to save the API Key in a safe place as it is not accessible after it has been created:
2) Prepare a Google Spreadsheet with at least two essential columns: one for the post's ID# (the post_id variable for single image posts, group_id for the multi-image posts) to reference an existing post on the site, and another for the variable to be updated. For example, if the post currently has title "6 Tactics to Generate More Revenue From Holiday Website Traffic" and needs to be updated to "7 Tactics to Generate More Revenue From Holiday Website Traffic", specify these details in the spreadsheet.
Note: The post_id or group_id variable is the only mandatory field for this process, and multiple data points can be updated simultaneously.
When setting up the file we recommend using our CSV import template file as a basis for the API sheet. The file has all of the correct database variables:
How To Import Posts Via CSV File
However, the column names do not necessarily match with the correct database variable names as this can be mapped later on.
How To Connect Google Sheets Using Zapier
In this example, we will be using Zapier to integrate Google Sheets into the Brilliant Directories site.
Log in to the Zapier account and click on Create Zap:
Name the new zap created and select the Google Sheets option as a Trigger:
Select the Event type as New Spreadsheet Row and click on Continue:
Connect the Google Sheet Account (this would be a Gmail account) and click on Continue:
Choose the preferred Spreadsheet, specify the Worksheet, and click on Continue:
Click on Test Trigger:
There will be a confirmation that a spreadsheet row has been found, click Continue:
Now the Trigger has been set up correctly, the Action can be created. Search and select the "Brilliant Directories" as the App option:
Choose the Update User event and click Continue:
If this is the first time creating a Brilliant Directories connection, click on the Sign In option:
If there is already a connection created to Brilliant Directories, click on Connect a new account option:
Clicking both options above will open a new window where the domain of the site (https:// or http:// included) and the API Key generated can be specified:
After clicking Yes, Continue on the window above, click on Continue:
Next, we will be setting up the action. In this section, all the available post variables can be found. As we already created a spreadsheet with a row of post data, the next action would be mapping/matching the column names to the correct variable names.
First, choose the post type:
Then, select the "Custom" option for Post ID field and select the post_id value from the spreadsheet:
Then, map the Post Title by selecting the post_title column for the "Post Title" field:
Now that all the preferred variables are matched and mapped correctly, click on Continue to test the action:
Confirm that the information displayed is correct and click on Test Step:
Make sure that the targeted field is updated:
Once confirmed, click on "Publish":
Note: Going forward, any new rows added to the connected Google Sheet via the API will automatically update the corresponding member data.