I need to send data of my spreadsheet to an other server, I've tried this.I am not getting error but its not working too.
I tried lots of things but no joy.
var ss = SpreadsheetApp.getActiveSpreadsheet();
function onOpen() {
var menuEntries = [ {name: "Send to PLM", functionName: "email"} ];
ss.addMenu("MyMenu", menuEntries);
}
function email() {
//Browser.msgBox("Hello World");
//var url = "http://********/noetic_Data/AddDataToAras?data=";
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var columns = sheet.getDataRange();
var numRows = rows.getNumRows();
var numColumns = rows.getNumColumns();
var values = rows.getValues();
for (var i = 0; i <= numRows - 1; i++) {
for (var j = 0; j <= numColumns - 1; j++) {
var row = values[i][j];
var cell = sheet.getRange(i+1,j+1);
}
}
Logger.log(numRows+"::"+numColumns);
var excelData = "";
for(var k=0;k<values.length;k++)
{
if(excelData == "")
{
excelData = values[k];
}
else
{
excelData = excelData +"|"+ values[k];
}
}
Browser.msgBox(excelData) ;
return excelData;
//var url = "http://*****/noetic_Data/AddDataToAras?data="+excelData;
var response = UrlFetchApp.getRequest("http://******/noetic_Data/AddDataToArasdata=", excelData)
//fetch("******/noetic_Data/AddDataToAras?data=", excelData);
Logger.log(response.getContentText());
// s = s+excelData;
//return s;
}
getRequest()will show what thefetchwould look like IF it was sent - but you haven't shown what you're getting. Youroptionsvalue is a string, but should be an object with specific names properties - the string is an object, everything in JavaScript is, it's just missing properties that would end up in theGETrequest. SetmuteHttpExceptions : truein the options forfetchso you can capture the response and examine it.