Answer the question
In order to leave comments, you need to log in
How to activate doGet(e) using UrlFetchApp?
How to use UrlFetchApp request to activate doGet(e) function in another google script?
I posted the script itself as a web application with the parameter "Who has access to the application: everyone, including anonymous users"
And if you just run it in the browser (and through incognito), then it works, but it doesn't.
The request itself.
var payload = {
"name" : "name",
};
var options = {
"method" : "GET",
"payload" : payload,
"followRedirects" : true,
"muteHttpExceptions": true
};
var url="https://script.google.com/macros/s/(id скрипта)/exec";
var resp=UrlFetchApp.fetch(url,options).getContentText();
function doGet(e) {
var Name = e.parameter.name;
return ContentService.createTextOutput(Name);
}
<!DOCTYPE html><html><head><link rel="shortcut icon" href="//ssl.gstatic.com/docs/script/images/favicon.ico"><title>Error</title><style type="text/css">body {background-color: #fff; margin: 0; padding: 0;}.errorMessage {font-family: Arial,sans-serif; font-size: 12pt; font-weight: bold; line-height: 150%; padding-top: 25px;}</style></head><body style="margin:20px"><div><img alt="Google Apps Script" src="//ssl.gstatic.com/docs/script/images/logo.png"></div><div style="text-align:center;font-family:monospace;margin:50px auto 0;max-width:600px">Script function not found: doPost</div></body></html>
{headers={X-Forwarded-For=187.121.239.122}, method=post, payload=name=name, followRedirects=true, validateHttpsCertificates=true, useIntranet=false, contentType=application/x-www-form-urlencoded, url=https://script.google.com/macros/s/AKfycbzSESoSAmLBYdA8MdiqSdcVJNCVB3dhg3vFSrQBNM7ydetz0So/exec}
Answer the question
In order to leave comments, you need to log in
They wrote to you:
This is probably because you are not sending a request GET
, but POST
a request. At a minimum GET
, it has no body
payload and does not need it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question