I’m trying to send data from google sheet using POST.
Actually it works, if I write data in code. But I wand to get it from google sheet
My code
function sendDataToRoistatAPI() {
var url = "https:XXX";
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheet = spreadsheet.getSheetByName("Users");
var data = sheet.getDataRange().getValues();
for (var i = 0; i < data.length; i++) {
var rowData = data[i];
var payload = {
manual_custom_metric_id: rowData[1],
source: rowData[2],
value: rowData[3],
period: rowData[4],
};
var options = {
method: "post",
contentType: "application/json",
payload: JSON.stringify(data),
};
var response = UrlFetchApp.fetch(url, options);
Logger.log(response.getContentText());
}
}
The mistake is
{“status”:”error”,”error”:”incorrect_request”,”description”:”Argument value is not a positive valuenRequired argument period is missingnArgument manual_custom_metric_id is not a positive integer number”}
In google sheet named Users I have colums: manual_custom_metric_id,source,value,period