我正在尝试为BuildCompleted事件实现Webhook。我被错误困住了:
错误请求(400)
从web界面测试服务钩子时。事件日志或IIS日志文件中似乎没有有关错误的详细信息。这个
寄存器
功能在
WebAPCONFIG
被击中,但构造器或
执行异步
在我的网络钩子不是。
任何帮助都将不胜感激!我敢肯定,这是一些琐碎的事情,我只是可以看到自己。
我的设置包括prem tfs 2018 update 2服务器和一个单独的windwos服务器2012,其中包含webhook的iis。我将global.asax和web.config部署到wwwroot,将程序集部署到wwwroot/bin。
网址:
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();
}
}
全局.asax.cs
public class Global : HttpApplication
{
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
}