I have created a Google Script and published it as a web app, very much like this post has.
However, I would like to call my extremely simple doGet
method using Postman. The web app is published with anonymous access and execution permission as me.
I was expecting to be able to paste the URL into Postman, set the GET
verb and hit Send
- and to see the same result I see in the browser. I do not.
What am I doing wrong?
[UPDATE] Responding to comment by themaster
I have created a Google Apps Script
called devices
in my Google Drive. I've added this function:
function doDelete(e) {
return HtmlService.createHtmlOutput('{"test":"yes"}');
}
Simple, I know, but should respond to a DELETE
request with:
{
"test": "yes"
}
I then hit Save
, followed by Deploy
> Publish as web app...
with the following options:
I hit Update
and get a URL like this:
https://script.google.com/macros/s/ABcdefgHInmLDGiHmpGmXkXIxMjsh0s61sKZ9ov6OOSpkb--1quTtfM/exec
If the function is named doGet
and I paste the URL into the browser, I see this JSON mentioned above.
If I leave the function named doDelete
and I make a DELETE
request from Postman, I get this:
Could not get any response There was an error connecting to https://script.google.com/macros/s/ABcdefgHInmLDGiHmpGmXkXIxMjsh0s61sKZ9ov6OOSpkb--1quTtfM/exec. Why this might have happened: The server couldn't send a response: Ensure that the backend is working properly Self-signed SSL certificates are being blocked: Fix this by turning off 'SSL certificate verification' in Settings > General Proxy configured incorrectly Ensure that proxy is configured correctly in Settings > Proxy Request timeout: Change request timeout in Settings > General
If I change the function to doGet
, republish and call it with a GET
request from Postman, I get the same result.
[EDIT] Clarification
If I make the Postman call using GET
and have the doGet
function setup to call an IFTTT webhook, the webhook does fire. I can also make it fire using the doPost
and a POST
request in Postman.
However, if I use doDelete
with a DELETE
request in Postman, the IFTTT webhook does not get called.
Regardless of the verb used in Postman I do not get a response - only the message quoted above.
[EDIT] Response to @sourabh-choraria question
My code currently is just this:
function doGet(e) {
return HtmlService.createHtmlOutput('{"valid":"no"}');
}
Published with the process described above, I get this when calling with Postman:
Could not get any response
I am making that request as a GET
without any headers.
Currently, Google Apps Script's Web Apps only support the following HTTP methods, as per their requirements for web apps -
doGet()
doPost()
While not explicitly stated in the reference doc that PUT, DELETE, UPDATE etc. are unsupported, there is no way to execute those HTTP methods via Web Apps in Apps Script.