# Validating webhook endpoint in Google Apps Script

**URL:** <https://devforum.zoom.us/t/validating-webhook-endpoint-in-google-apps-script/110443>\
**Category:** API and Webhooks\
**Created:** [May 22, 2024, 3:49am UTC](https://devforum.zoom.us/t/validating-webhook-endpoint-in-google-apps-script/110443 "2024-05-22T03:49:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkofman](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/bkofman/32/59942_2.png) [@bkofman](https://devforum.zoom.us/u/bkofman)\
**Post date:** [May 22, 2024, 3:49am UTC](https://devforum.zoom.us/t/validating-webhook-endpoint-in-google-apps-script/110443/1 "2024-05-22T03:49:59Z")

</div>

I’d like to use Google Apps Script to process events. But I can’t get past the validation of the endpoint, I keep getting “URL validation failed. Try again later.” Here’s the code.

```auto
function doPost(e) {
    // Parse the JSON payload from the request
    var requestData = JSON.parse(e.postData.contents);
    if (requestData.event === "endpoint.url_validation") {

      // Extract the plainToken from the payload
      var plainToken = requestData.payload.plainToken;

      // Create HMAC SHA-256 hash using the secret token as the key and plainToken as the message
      var encryptedToken = Utilities.computeHmacSha256Signature(plainToken, WEBHOOK_SECRET_TOKEN);

      // Convert the byte array to a hex string
      encryptedToken = encryptedToken.map(function (byte) {
        var hexString = (byte & 0xFF).toString(16);
        return (hexString.length === 1) ? '0' + hexString : hexString;
      }).join('');

      // Create a response object with both tokens
      var response = {
        plainToken: plainToken,
        encryptedToken: encryptedToken
      };

      // Convert the response object to JSON
      var jsonResponse = JSON.stringify(response);

      // Return the JSON response
      return ContentService.createTextOutput(jsonResponse).setMimeType(ContentService.MimeType.JSON);
   }
}

```

It executes without errors.  
What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [May 25, 2025, 7:26pm UTC](https://devforum.zoom.us/t/validating-webhook-endpoint-in-google-apps-script/110443/2 "2025-05-25T19:26:11Z")

</div>

Closed on May 25, 2025, 7:26pm UTC

This topic was automatically closed 368 days after the last reply. New replies are no longer allowed.
