0

I cannot seem to find a way to set a URI like this for generic asp.net webhooks with a route that begins with something like /portalapi/v1/*. E.g. something like this:

    config.Routes.MapHttpRoute(
        name: "PortalApi",
        routeTemplate: "portalapi/v1/{controller}/{id}",
        defaults: new { id = RouteParameter.Optional }
    );

The webhook receiver only seems to respond to posts from URIs in the form api/*:

   config.Routes.MapHttpRoute(
        name: "DefaultApi",
        routeTemplate: "api/{controller}/{id}",
        defaults: new { id = RouteParameter.Optional }
    );

Am I missing something? Or is this a bug? Has anyone been able to change the beginning of the route and have it accepted by the webhook call?

I read through this microsoft documentation, but didn't find any answers: https://learn.microsoft.com/en-us/aspnet/webhooks/receiving/receivers

I have an open ticket with the AspNetWebHooks team on github. https://github.com/aspnet/AspNetWebHooks/issues/62

Cale Sweeney
  • 1,014
  • 1
  • 15
  • 37

1 Answers1

1

You can't, because it's not supported, and the project is in maintenance mode so it won't ever be supported.

Look at the source code:

// Use a constant template since all WebHook constraints use the resulting route values and we have no
// requirements for user-specified route templates.
private static string ChooseTemplate()
{
    var template = "/api/webhooks/incoming/"
        + $"{{{WebHookConstants.ReceiverKeyName}}}/"
        + $"{{{WebHookConstants.IdKeyName}?}}";

    return template;
}
Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
  • thanks for pointing that out. I'll let the github team know they should add that to the documentation. Are there other newer webhook projects for asp.net that are currently in development, i.e. not maintenance mode? – Cale Sweeney Oct 26 '21 at 14:09