我有:
我的目标是Azure函数的URL接收来自软件的web钩子的通知并执行一个操作。Azure逻辑应用程序只用于测试。
什么起作用
什么不起作用
Azure函数的URL
这是来自Get函数URL >默认值(函数键)。
https://<app_name>.azurewebsites.net/api/content?code=<api_key>其他Azure函数配置设置
GET、POST我相信这个JSON会通过网络钩子
{
"headers": {
"Expect": "100-continue",
"Host": "redacted",
"X-Telligent-Webhook-Sender": "redacted",
"Content-Length": "16908",
"Content-Type": "application/json; charset=utf-8"
},
"body": {
"events": [{
"TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
"DateOccurred": "2018-12-17T22:55:37.7846546Z",
"EventData": {
"ActorUserId": 9999,
"ContentId": "redacted",
"ContentTypeId": "redacted",
"ForumReplyId": 9999,
"ForumThreadId": 9999,
"ForumId": 9999
}
}]
}
}对于相同的结果,我还尝试使用以下测试代码。它与软件公司提供的样本有效载荷数据更加一致:
我试过什么
{
"events": [{
"TypeId": "ec9da4f4-0703-4029-b01e-7ca9c9ed6c85",
"DateOccurred": "2018-12-17T22:55:37.7846546Z",
"EventData": {
"ActorUserId": 9999,
"ContentId": "redacted",
"ContentTypeId": "redacted",
"ForumReplyId": 9999,
"ForumThreadId": 9999,
"ForumId": 9999
}
}]
}{
"events": [
{
"TypeId": "407ad3bc-8269-493e-ac56-9127656527df",
"DateOccurred": "2015-12-04T16:31:55.5383926Z",
"EventData": {
"ActorUserId": 2100,
"ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
}
},
{
"TypeId": "3b75c5b9-4705-4a97-93f5-a4941dc69bc9",
"DateOccurred": "2015-12-04T16:48:03.7343926Z",
"EventData": {
"ActorUserId": 2100,
"ContentId": "4c792b81-6f09-4a45-be8c-476198ba47be"
}
}
]
}我不知道如何确定为什么Azure函数不是由web钩子触发的。该软件的API文档似乎没有提供一种方法来查看通过web钩子发送的JSON,尽管在我缺乏经验的情况下,我可能错了。
Azure、Postman或其他工具中是否有一种机制可以让我看到在web钩子上发送了什么JSON?或者,是否有另一种方法来确定问题的原因?
谢谢你的帮助。
发布于 2019-08-24 12:17:51
这就是我如何从Azure警报中获得JSON文件的方式。
gem install sinatra安装Sinatrawebhook.rb并粘贴下面的代码require 'sinatra'
set :port, 80
set :bind, '0.0.0.0'
post '/event' do
status 204 #successful request with no body content
request.body.rewind
request_payload = JSON.parse(request.body.read)
#append the payload to a file
File.open("events.txt", "a") do |f|
f.puts(request_payload)
end
endruby webhook.rb运行web服务events.txthttps://stackoverflow.com/questions/53972297
复制相似问题