我正在尝试构建JSON Webhook,已经配置了接收器和Webhook处理程序。我正在尝试将从Webhook接收的POST数据保存到我的SQL Server。但是我无法。
当我向Webhook URL发出HTTP请求时,我有200 OK响应,并且Webhook处理程序中的调试点从未命中。我无法解决问题,请帮帮我。
下面是我的Webhook处理程序和接收器配置以及Global.ascx
WEBHOOK处理程序
const OptimizeCssAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const CompressionPlugin = require("compression-webpack-plugin");
require('babel-register');
module.exports = {
entry: './src/js/app.js',
output: {
path: __dirname + "/src/js/",
filename: 'app.bundle.js'
},
mode: 'development',
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
extractComments: true
}),
new OptimizeCssAssetsPlugin({}),
new CompressionPlugin()
]
},
module: {
rules: [
{
test: /\.scss$/,
use: [
{loader: "style-loader"},
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: 'ko_[sha1:hash:hex:3]'
}
},
{
loader: "sass-loader"
}
]
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: "babel-loader",
query: {
presets: ['react', 'es2015']
}
},
{
test: /\.js?$/,
exclude: /node_modules/,
loader: "babel-loader",
query: {
presets: ['react', 'es2015']
}
}
]
},
};
RECEIVER
public CustomWebHookHandler()
{
this.Receiver = "genericjson";
}
public override Task ExecuteAsync(string generator, WebHookHandlerContext context)
{
//CustomNotifications notifications = context.GetDataOrDefault<CustomNotifications>();
//return Task.FromResult(true);
JObject dataJObject = context.GetDataOrDefault<JObject>();
Console.Write("Data rx from webhook " + dataJObject.ToString());
return Task.FromResult(false);
}
Global.ascx
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
var controllerType = typeof(WebHookReceiversController);
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.InitializeReceiveGenericJsonWebHooks();
}
}
调试点从未到达Webhook处理程序方法ExecuteAsync,我试图将数据保存到文件或数据库中。我对此很陌生,如果有人有一个想法,请帮助我。谢谢