How to parse data to Google Sheets through Web API

Hi! I would like to parse 28 data to Google Sheets, creating a new row, through Web API, because I need to calculate the distance between the values entered in the current row and the values stored in previous rows. I know there is built-in blocks to connect to Google Sheets, but I need to do some calculations and App Script is the appropriate way.

This is my script

function doPost(e) {

try {

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“entries”);

const data = JSON.parse(e.postData.contents);

sheet.appendRow([data.field1, data.field2, data.field3, data.field4, data.field5, data.field6, data.field7, data.field8, data.field9, data.field10, data.field11, data.field12, data.field13, data.field14, data.field15, data.field16, data.field17, data.field18, data.field19, data.field20, data.field21, data.field22, data.field23, data.field24, data.field25, data.field26, data.field27, data.field28]);

return ContentService.createTextOutput(JSON.stringify({ result: “ok”, data: row })).setMimeType(ContentService.MimeType.JSON);

}

catch (error) {

return ContentService.createTextOutput(JSON.stringify({ result: "error", message: error.message })).setMimeType(ContentService.MimeType.JSON);

}

}

Welcome to Thunkable! What is and is not working? What is your question?