title: Unable to parse x-www-form-urlencoded using Apps Script (Webhooks)
body: <p>I'm trying to get POST request in Gsheet using Apps Script (as a Webapp)! It works well for JavaScript body POST type but when I tried with x-www-form-urlencoded there is an error.</p>
  
  <pre><code>function doPost(e) {
  
  //Return if null
    if( e == undefined ) {
        console.log("no data");
        return HtmlService.createHtmlOutput("need data");
      }
  
  //Parse the JSON data
  
    var event = JSON.parse(e.postData.contents);
    var data = event.data;
  
  
  //Get the last row without data
  
    var sheet = SpreadsheetApp.getActiveSheet();
    var lastRow = Math.max(sheet.getLastRow(),1);
    sheet.insertRowAfter(lastRow);
  
  //Get current timestamp
  
    var timestamp = new Date();
  
  //Insert the data into the sheet
  
    sheet.getRange(lastRow + 1, 1).setValue(event.bt_signature);
    sheet.getRange(lastRow + 1, 2).setValue(data.bt_payload);
    SpreadsheetApp.flush();
  
    return HtmlService.createHtmlOutput("post request received");}
  </code></pre>
  
  <p>Thanks!</p>