Enable Webhook Responds 404 Not Found

Hi Guys,

I am new to creating webhooks so I apologize if this is something simple. I am using C# to register my webhook with the api. That works as intended.

Then, I am calling all of the webhooks for the sheet using

`SheetResources.ListSheets(null, null, null)` which also returns the list of webhooks fine.

Then I am retrieving the webhook Id from this result

Then I am attempting to "enable" the webhook using

WebhookResources.UpdateWebhook(Options) <--- this is where it gives me 404 not found


I am not sure what I am going wrong here.


Any advice to check?

Tags:

Answers

  • kskarz
    kskarz ✭✭✭✭

    Hi @gmedia

    As per docs:

    A webhook is not enabled by default when it is created. Once you've created a webhook, you can enable it by using the Update Webhook operation to set enabled to true.

    The ID of the webhook you can find in the response when you create a webhook.


    Or you can call https://api.smartsheet.com/2.0/webhooks

    Loop over the response to find your webhook ID based on the "scopeObjectId" which is your sheet ID. Then Update webhook to Enable it:

    https://api.smartsheet.com/2.0/webhooks/{webhookId}


    Follow the docs and you should be ok.

  • That is exactly what I am doing. I am trying to "enable" the webhook by using the update. The request to update it is failing


    Webhook Options = new Webhook();

    Options.Id = WebhookId;

    Options.Enabled = isEnabled;

    UpdatedWebhook = this._Client.WebhookResources.UpdateWebhook(Options);

  • kskarz
    kskarz ✭✭✭✭

    check your "callbackUrl". Are you sure the endpoint is set correctly to receive the request? Also, are you returning the WebhookChallenge code if required?


    To debug this I would log any incoming requests at the callbackUrl and check if one was received from Smartsheet after you send the updateWebhook request.

    It's hard to help without understanding how your endpoint is configured.

  • I'm not sure if I have the callback function correct. How should it be set in C#

        private static async Task<IResult> SpreadsheetEvent(HttpContext HttpCtxt)

        {       

          Console.WriteLine(HttpCtxt.Request.Headers.ToString());

          return Results.Ok();

        }