1

Disclaimer: I am not knowledgeable about Google Script, so detailed explanations of the issue would be much appreciated

My goal is to reproduce the steps from this page: https://www.labnol.org/send-sms-google-sheets-200402

However I receive the following message while trying to Debug doPost.

The full script used is:

const SHEET_URL ="myurl";

const SHEET_NAME = "SMS";

const doGet = () => {
    const sheet = SpreadsheetApp.openByUrl(SHEET_URL).getSheetByName(
        SHEET_NAME
    );
    const [header, ...data] = sheet.getDataRange().getDisplayValues();

const PHONE = header.indexOf('Phone');
const TEXT = header.indexOf('Text');
const STATUS = header.indexOf('Status');

const output = [];

data.forEach((row, index) => {
        if (row[STATUS] === '') {
            output.push([index + 1, row[PHONE], row[TEXT]]);
        }
    });

const json = JSON.stringify(output);

return ContentService.createTextOutput(json).setMimeType(
        ContentService.MimeType.TEXT
    );
};

const doPost = (e) => {
    const sheet = SpreadsheetApp.openByUrl(SHEET_URL).getSheetByName(
        SHEET_NAME
    );
    const [header] = sheet.getRange('A1:1').getValues();
    const STATUS = header.indexOf('Status');
    var rowId = Number(e.parameter.row);
    sheet.getRange(rowId + 1, STATUS + 1).setValue('SMS Sent');
    return ContentService.createTextOutput('').setMimeType(
        ContentService.MimeType.TEXT
    );
};
Pierre
  • 11
  • 1
  • 1
    You can't debug doPost(e) from the script editor unless you provide the event object. If that's how your getting the error then it probably has nothing to do with the real problem. – Cooper Apr 18 '21 at 02:44
  • If you run `doPost` manually from the script editor, `e` won't be defined. Have you tried making a `POST` request to your script URL? Is it working as intended? – Iamblichus Apr 19 '21 at 11:05

0 Answers0