I've recently come accross the same requirement to read the rows of the sheet and send the data in request and record the response. I thought I would share what I worked out after googling a bit...
function testing_this() {
var data = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
for (row in data) {
Logger.log(data[row]);
var row = data[row]
var options = {
'method': 'post',
'payload': { email:row[1]}
};
// sending to API. for example:
UrlFetchApp.fetch('https://your-rest-api-url/v1/customers/', options);
}
}
If you want to get the data in the sheet you should use the function:
var response = UrlFetchApp.getRequest("http://your-api-url/");
for(data in response) {
var respData = response[data];
// do whatever u want to do with this data...
}
Hope it is useful to you all who are facing similar requirement as above.
I've posted this script in github if you want to fork/pull...
https://github.com/joshiparthin/gsheetScriptExperiments/blob/master/readAndSendToApi.js
Cheers,
Parth