Reputation: 135
I am getting some issue when taking value form parameter here is my simple code in Google App script and deployed service. what is the issue ?
function doGet(e) {
var num = e.parameter.num;
var result=false;
result=(num%2==0);
if(result){
return ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.XML);
}else{
return ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.XML);
}
}
Here is google appscript deployed url
This error I am getting when I am hitting this url
and code running error in App-script Environment
Upvotes: 2
Views: 497
Reputation: 46822
it seems that the issue might come from the modulo operation you are trying to apply to a string value, when I try this code it runs without error
function doGet(e) {
var num = Number(e.parameter.num);// make it a number before testing parity
var result=false;
result=(num%2==0);
var xmlContent = '<mydata>' + result+ num + '</mydata>';// added num value for test purpose
if(result){
return ContentService.createTextOutput(xmlContent).setMimeType(ContentService.MimeType.XML);
}else{
return ContentService.createTextOutput(xmlContent).setMimeType(ContentService.MimeType.XML);
}
}
That said, I suppose this is just a test code because I don't really see what it can be used for and the xml output is not valid but I'll leave you with that issue.
Upvotes: 1