I am trying to implement a WebHook for the BuildCompleted event. I am stuck with the error: Bad Request (400) when testing the service hook from the web interface. There seems to be no detailed information about the error in the Event Log or the IIS log files. The Register function in WebApiConfig is hit but the constructor or ExecuteAsync in my WebHook is not.
Any help would be highly appreciated! I am sure that it is some trivial that I just can seem to see myself.
My setup consists of on-prem TFS 2018 Update 2 server and a seperate Windwos Server 2012 with IIS for the the WebHook. I deploy Global.asax and web.config to wwwroot and the assemblies to wwwroot/bin.
Url: http://MYSERVER/api/webhooks/incoming/genericjson?code=83699ec7c1d794c0c780e49a5c72972590571fd8
web.config:
...
<appSettings>
<add key="MS_WebHookReceiverSecret_GenericJson" value="83699ec7c1d794c0c780e49a5c72972590571fd8" />
</appSettings>
...
WebHookHandler:
public class GenericJsonWebHookHandler : WebHookHandler
{
public GenericJsonWebHookHandler()
{
this.Receiver = GenericJsonWebHookReceiver.ReceiverName;
}
public override Task ExecuteAsync(string receiver, WebHookHandlerContext context)
{
return Task.FromResult(true);
}
}
WebApiConfig:
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new {id = RouteParameter.Optional}
);
// Initialize GenericJson WebHook receiver
config.InitializeReceiveGenericJsonWebHooks();
}
}
Global.asax.cs
public class Global : HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}