I am trying to make an HTTP POST request when Google Spreadsheet loads.
I have gotten my HTTP POST request working as a function in a menu dropdown but I can't get it to work with onOpen
or onInstall
.
Here is the code:
function onOpen(){
var url = "http://example.com/collect";
var options = {
"method": "post",
"payload": {
"v":"1",
"data1":"hello",
"data2":"5553",
"data3":"test"
}
}
Logger.log('worked');
UrlFetchApp.fetch(url, options);
}
Is it possible to make an HTTP POST request when a spreadsheet loads? If so, do you see anything wrong with my code?
If you read the documentation about permissions and simple triggers, you will learn that simple triggers can't do anything that requires authorization because they run under the authority of the "user at the keyboard" and do it silently.
Change the function name and create an installable onOpen trigger that will be executed as yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With