Reputation: 149
I've tried testing the app by sending requests through Postman, but I get a login webpage as a response. I enabled "Access by anyone, even anonymous" when deploying the app, so I wouldn't that that a user needs to log in to trigger the webhook.
I want to be able to run my script just by sending a POST request with some data from a raspberry pi python script.
Here is the code I'm working with:
function doGet(e) {
Logger.log('I got a GET request');
spreadsheet.appendRow(['test1', 'test2', '', 'test4']);
return HtmlService.createHtmlOutput('<b>Hello, world!</b>');
}
function doPost(e) {
Logger.log('Got a POST.');
return HtmlService.createHtmlOutput('Success');
}
Upvotes: 0
Views: 82
Reputation: 149
Thank you @Sandy Good.
I have found out that I was using the wrong URL the entire time, ending with /dev. I never realized there were two URLs, and after switching from /dev to the /exec URL, it works now.
Upvotes: 1
Reputation: 31310
Whenever you make a change to the code, you must constantly publish a new version. Even the slightest change, you must publish a new version and make sure that you are using the version with "exec" on the end.
You have:
return HtmlService.createHtmlOutput('<b>Hello, world!</b>');
Which does not technically create content. It creates something like an HtmlService object. I'm not sure what the exact official term is, but in any case, you need to "chain" .getContent()
to the end:
h = HtmlService.createHtmlOutput('<b>Hello, world!</b>').getContent();
That returns a string. You might be able to return that. If not, try using Content Service.
Might also try:
var c,h;
h = HtmlService.createHtmlOutput('<b>Hello, world!</b>').getContent();
c = ContentService.createTextOutput(h);
return c;
Upvotes: 0