Webhook help!

I am using google app scripts to try and receive a webhook. I would like to pull just the ID number and then trigger an api pull to do other things. However, I cannot get the first part of my script to work and it keeps failing. can someone help me understand what I am missing here? below is the script code from my GAS instance.

function doPost(e) {

var params = JSON.stringify(e.postData.contents);

var data = JSON.parse(params)[“meta”][“id”];

// I think its failing somewhere above this line
var ss = SpreadsheetApp

var getSS = ss.openByUrl(THE URL I USE)

getSS.getSheetByName(“THE SHEETS NAME”).getRange(1,1).activate().setValue(data)


Hi @Data_Analyst

Based on Google Script docs, POST request content is in text (string) format, hence there is no need to stringify it and parse again.

function doPost(e) {
    // parse content from text to json
    // read more about that here https://developers.google.com/apps-script/guides/web#request_parameters
    var body = JSON.parse(e.postData.contents);
    var id = body.meta.id;

    // just for a test 
    return ContentService.createTextOutput("Here is ID: " + id);

Holy Smokes! such a life saver lol! Thank you for that. this solved my problem!

1 Like

I did not realize it came in as a string. That made all the difference