SmartSheet webhook -> Google Apps Script verification

Hello,

I'm trying to set up Smartsheet's webhook listener using Google Apps Script, but having an issue with the verification step.

My code looks as follows:
function doPost(e) {
var challenge = JSON.parse(e.postData.contents).challenge;
var response = JSON.stringify({'smartsheetHookResponse':challenge});
return ContentService.createTextOutput(response).setMimeType(ContentService.MimeType.JSON);
}

The error I'm receiving when trying to activate the webhook is "Request returned HTTP status code 302" which I believe is due to this part:


"For security reasons, content returned by the Content service isn't served fromscript.google.com, but instead redirected to a one-time URL atscript.googleusercontent.com. This means that if you use the Content service
to return data to another application, you must ensure that the HTTP client is
configured to follow redirects. For example, in the cURL command line utility,
add the flag -L. Check the documentation for your HTTP client for more
information on how to enable this behavior."

Is there a way to make Smartsheet follow the redirect to receive the challenge or create HtmlService.createHtmlOutput that is a vaild response (as the HtmlService is not redirecting)?

Answers