Help! Webhook Creation Error

Hello!

I'm able to use my api key to retrieve my sheet, and then the /webhook GET request successfully responds with an empty set, but I'm unable to add the hook for some reason. Any help would be appreciated! I've tried adding the non-required fields shown in the docs (createdAt, modifiedAt, subscope) and I've tried setting the enabled flag to false (who knows) each resulting with the same error.

Thanks y'all.


Best Answer

  • Adam HILLIKER
    Answer ✓

    Thank you this is helpful - the POST call I'm making is the equivalent of your CreateWebhook() call.

    Interestingly, their documentation states: "Currently, must be an array of size 1 that contains the string value ".", which means "all objects" and "all events"." -- and their example code had:

    "events": ["*"]

    Both of which are incorrect! I tried your value of

    "events": ["*.*"]

    and that worked! Thank you!

    If the API docs team is reading, please update the docs!

Answers

  • BKing
    BKing ✭✭✭

    We have a two stage process (I'm afraid this is c# from our api wrapper)

          long inpHook = await smartSrv.CreateWebHook(sheetId);

          Assert.NotEqual(0, inpHook);

          long rtnHook = await smartSrv.EnableWebHook(sheetId, inpHook);

          Assert.NotEqual(0, rtnHook);


    Create does this:

              // Webhook specification

              Webhook webhook = new Webhook

              {

                Name = "APD Webhook",

                CallbackUrl = awsCred.SmartAPIString,

                Scope = "sheet",

                ScopeObjectId = sheetId,

                Events = new string[] { "*.*" },

                Version = 1

              };

              // Create Webhook

              Webhook newWebhook = smartsheet.WebhookResources.CreateWebhook(

               webhook

              );

              hookId = (long)newWebhook.Id;


    // hookId allows us to pass value to enable.

    Enable does this:

              Webhook webhook = new Webhook

              {

                Id = webhookId,

                CallbackUrl = awsCred.SmartAPIString,

                Version = 1,

                Enabled = true

              };

              // Update Webhook

              Webhook updatedWebhook = smartsheet.WebhookResources.UpdateWebhook(webhook);

              hookId = (long)updatedWebhook.Id;


    Call back url is help in an AWS secret vault.

    Regards

    Brian

  • Adam HILLIKER
    Answer ✓

    Thank you this is helpful - the POST call I'm making is the equivalent of your CreateWebhook() call.

    Interestingly, their documentation states: "Currently, must be an array of size 1 that contains the string value ".", which means "all objects" and "all events"." -- and their example code had:

    "events": ["*"]

    Both of which are incorrect! I tried your value of

    "events": ["*.*"]

    and that worked! Thank you!

    If the API docs team is reading, please update the docs!

  • Hi @Adam HILLIKER

    Thank you for identifying what needs to be updated in the new API Documentation! I've passed along your feedback to the documentation team.

    Cheers,

    Genevieve

    Need more help? 👀 | Help and Learning Center

    こんにちは (Konnichiwa), Hallo, Hola, Bonjour, Olá, Ciao! 👋 | Global Discussions