WebHookActor does not seem to trigger

Vote:
 

Trying to setup a method receiving data from Forms webhooks and have an APiController to recieve the data. Trying the address from Postman all works fine but when setting up the form with the same webhook url the recieving method is not triggered. No error i visible inte logs and the EmailActor is working. How do I debug this?

The receiving controller looks like this trying to debug this

[RoutePrefix("api/formswebhooks")]
    public class FormsWebhooksController : ApiController
    {
        private static readonly ILogger Logger = LogManager.GetLogger(typeof(FormsWebhooksController));

        [Route("genericform")]
        [HttpPost]
        public string GenericForm([FromBody]JToken jsonbody)
        {
            try
            {
                string name = jsonbody["Name"]?.ToString();
                File.WriteAllText(@"C:\OutputFolder\webhook.txt", jsonbody.ToString());
            }
            catch (Exception e)
            {
                Logger.Error("Failed to process webhook!", e);
            }

            return string.Empty;
        }
    }

Update: 

Running the site in IISExpress from Console only displays this call, as otherwise would display the webhook call aswell as explained here: [Episerver form addon] webhook is not being fired | Optimizely De

#260052
Edited, Aug 04, 2021 11:08
Vote:
 

Do you mind me asking, what's your use case for doing this as a WebAPI, are you putting this in another project/solution outside of the CMS application?

Have you tried hitting the hook via Postman to make sure your routing is working? Attribute routing needs to be enabled as part of the WebAPI configuration?

#260053
Aug 04, 2021 11:21
Tobias Gladh - Aug 04, 2021 11:28
Hi as I said in the post, hitting the url in postman works. And this setup is only for debugging purpose to se the fields tha are posted in the Webhook so I know how to build the real implementation later. I just wanted to get the data out, and setting breakpoints in VS did not trigger so was thinking it might get trigger in some other way, That's why I tried output it to a file. But the lack of trigger in VS is probably due to the fact that the WebHookActor is not treggered at all for some reason.
Tobias Gladh - Aug 04, 2021 11:33
I have tried the regular MVC ActionControllerBase aswell but since nothing seems to work I have tried different things including the ApiController
Scott Reed - Aug 04, 2021 11:48
Ah if you want to just see the data I just use a webhook test service like https://webhook.site/ to check the data. They are free and you can see and download the exact payload
Scott Reed - Aug 04, 2021 11:50
You could also just create the endpoint in a postman under a collection and run it in a mock server, then you can see all of the data through that
Tobias Gladh - Aug 04, 2021 11:56
Thanks for the suggestions of webhooks.site will add that to my toolbox but as you see from my update in the post the webhook call clearly isn't sent at all so there is something wrong with the sites setup or something but quite unclear what the issue could be.
Tobias Gladh - Aug 04, 2021 12:04
Hmm, using the webhooks.site I get a post so the problem seems to be how the receiving method is setup
Vote:
 

Ok the error seems to be something with the devlopment environment since it clearly triggers the webhook, as tested with webhook.site (very good tool), and the code works when trying it on stage environment. If I find the cause and the solution can be of use here I will post it.

#260061
Aug 04, 2021 12:33
Tobias Gladh - Aug 04, 2021 12:45
Found the error. Due to my local setup with the site running on https with a mkcert-created certificate the call to the endpoint could not be made. Switching to http or running in an environment with a real certificate the code works and the call is made correctly.
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.