Created
March 19, 2022 17:21
-
-
Save mathetos/a189a1666573e8c2bb77e52fff316c3d to your computer and use it in GitHub Desktop.
Google Script to Process Webhook JSON and add Row in Google Sheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doPost(e) { | |
var body = e.postData.contents; | |
var bodyJSON = JSON.parse(body); | |
var ss = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = ss.getSheetByName("Submissions"); | |
var timeStamp = new Date(); | |
var time = Utilities.formatDate(timeStamp, "GMT-08:00", "MM/dd/yy, h:mm a"); | |
var lastRow = sheet.getLastRow(); | |
//Insert the data into the sheet | |
sheet.getRange(lastRow + 1, 1).setValue(bodyJSON["firstName"]); | |
sheet.getRange(lastRow + 1, 2).setValue(bodyJSON["lastName"]); | |
sheet.getRange(lastRow + 1, 3).setValue(bodyJSON["email"]); | |
sheet.getRange(lastRow + 1, 4).setValue(bodyJSON["pluginURL"]); | |
sheet.getRange(lastRow + 1, 5).setValue(bodyJSON["freeFreemium"]); | |
sheet.getRange(lastRow + 1, 6).setValue(bodyJSON["addonURL"]); | |
sheet.getRange(lastRow + 1, 7).setValue(bodyJSON["proURL"]); | |
sheet.getRange(lastRow + 1, 8).setValue(bodyJSON["marketingInfo"]); | |
sheet.getRange(lastRow + 1, 9).setValue(bodyJSON["background"]); | |
return HtmlService.createHtmlOutput(200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Step 1: Add Apps Script
Step 2: Paste script into
Code.gs
Step 3: Deploy as Web App
Step 4: Copy Webapp URL
Step 5: Confirm/Debug with Postman
Step 6: Confirm the rows are created in your spreadsheet