aspnet / WebHooks

[Archived] Libraries to create and consume web hooks on ASP.NET Core. Project moved to https://github.com/aspnet/AspLabs
Apache License 2.0
627 stars 439 forks source link

Question: Verification Request #102

Closed lukasv1 closed 7 years ago

lukasv1 commented 7 years ago

Hi, its possible change verification WebHook request from GET to POST? Thank you Lukas

HenrikFrystykNielsen commented 7 years ago

No but you can skip it altogether if you include a 'noecho' query parameter in your WebHook URI. Then no GET request will be sent.

lukasv1 commented 7 years ago

Thank you. We are implementing Microsoft Flow (Triggers) and Web Hook URI is from Flow.... But im not sure, if we can include this parametr to their WebHook URI.

HenrikFrystykNielsen commented 7 years ago

It's my understanding that you can -- let me know how it goes!

lukasv1 commented 7 years ago

Our scenario is sending WebHooks on Microsoft Flow https://flow.microsoft.com/en-us/.

Implementation is realized via Microsoft.AspNet.WebHooks.Custom / SqlStorage / API / MVC. Everything is OK, but in registration process (to MSSQL in our side) FLOW provide Web Hook URI

https://prod-00.westeurope.logic.azure.com/workflows/14b08aeb4cac40e692cfbcdb7f6b63fd/triggers/When_a_new_ticket_is_created/versions/08587173943290437095/run?api-version=2016-06-01&sp=%2Ftriggers%2FWhen_a_new_ticket_is_created%2Fversions%2F08587173943290437095%2Frun%2C%2Ftriggers%2FWhen_a_new_ticket_is_created%2Fversions%2F08587173943290437095%2Fread&sv=1.0&sig=lhrNilJxZjFXQ2Xp13FumjiIp0RAgp_D8fkCWpoCQI4

occures problem , because validation request to WebHook URI (above) is GET but FLOW expect POST.

Text { "Message": "WebHook verification failed. Please ensure that the WebHook URI is valid and that the endpoint is accessible. Error encountered: BadRequest" }

lukasv1 commented 7 years ago

Any idea how to tackle this problem? Thank you!

HenrikFrystykNielsen commented 7 years ago

I have been thinking about it but I am still confused -- the URI above is flow's generated URI for where to send a WebHook? That is, it wants to register that URI so that you can send it a WebHook when an event is triggered? What control do you have of that URI? Can you add a query parameter to it so that it includes '&noecho'?

lukasv1 commented 7 years ago

Yes, URI is from FLOW for sending WebHook - URI is generated by Flow and we can't add a query parametr... https://flow.microsoft.com/en-us/documentation/customapi-webhooks/ Thank you!

lukasv1 commented 7 years ago

...problem is only with GET request from validation

HenrikFrystykNielsen commented 7 years ago

The solution that we are working on for #104 will help this as well -- it will make it much easier to tailor the registration process to whatever you want.

HenrikFrystykNielsen commented 7 years ago

I just committed 757530d2af40da1d51e0cf387595561e1e5cebf0 which makes it much simpler to write your own WebHook registration mechanism whether that is a separate API controller, an MVC controller, or something else entirely. This also gives you full control over how much verification you want to do. Please see the commit for details -- you might be able to look at the existing WebHookRegistrationsController.cs for an example of how it is used.