I'm building a solution in which the amount of parameters added to an HTTP get request is variable. This means the URL can carry 1 to n amount of parameters. The parameters in the URL are identified with a standard name and attached index. Here is a sample URL:
How do I interpret the variable amount of Parameters in my doGet() Function in .gs?
EDIT: I want to create with this request the header of a new google sheet. The variable amount of parameters is supposed to be the column headers. E.g. if the request contains 5 parameters, I want to add in the first row of the google sheet into columns 1 to 5 the respective values of the parameters.
I tried the following code but it is not working:
function doGet(request) {
var FileNameString = request.parameter.fileName; //name of the new .gs file
var FridgeItems = request.parameter.fridgeItems; //amount of parameters/column headers passed to .gs
var sheet = SpreadsheetApp.create(FileNameString);
for(var i=0; i<FridgeItems ; i++){
sheet.getRange(1,i+2)
.setValues(
sheet.appendRow([request.parameter.fridgeItem&i]);
);
}
}
}