我有:
我的目标是Azure功能的URL从软件的Webhook接收通知并执行操作。 Azure Logic应用仅用于测试。
这是从获取功能URL > 默认(功能键)获得的。
https://<app_name>.azurewebsites.net/api/content?code=<api_key>
GET
,POST
{
"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"
}
}
]
}
我不知道如何确定为什么Webhook不触发Azure功能。该软件的API documentation似乎没有提供一种方法来查看通过Webhook发送的JSON,尽管根据我的经验,我可能是错的。
Azure,Postman或其他工具中是否存在一种机制,可以让我查看通过Webhook发送的JSON?也许还有另一种方法可以确定问题的原因?
谢谢您的帮助。
答案 0 :(得分:1)
这就是我从Azure警报中获取JSON文件的方式。
gem install sinatra
webhook.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
end
ruby webhook.rb
events.txt