代码之家  ›  专栏  ›  技术社区  ›  Tore Østergaard

genericjson webhook返回错误的请求

  •  0
  • Tore Østergaard  · 技术社区  · 6 年前

    我正在尝试为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);
        }
    }
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Tore Østergaard    6 年前

    这只是一个需要https的genericjsonwebhookreceiver的问题,它实际上是由文档指定的。

    GenericJsonWebHookReceiver class decleration

    我被tfs服务hook add屏幕抛出,只推荐https: enter image description here

    This answer 使我更仔细地查看异常中的响应 回应指令 打电话到服务台。

    {“消息”:“webhook接收器‘genericjsonwebhookreceiver’需要https才能安全。请注册'https'类型的webhook uri。'}