我拼命尝试了5天,以创建一个Elasticsearch Watcher警报,该警报在传入的Webhook团队中发送通知。但是,我收到的答案是“通用传入Webhook收到的有效负载错误”。我不明白为什么它不起作用。
{
"trigger": {
"schedule": {
"interval": "2m"
}
},
"input": {
"simple": {
"summary": "Test Nom",
"text": "test"
}
},
"condition": {
"always": {}
},
"actions": {
"MS_TEAMS_PORT443": {
"webhook": {
"scheme": "https",
"host": "outlook.office.com",
"port": 443,
"method": "post",
"path": "/webhook/XYZ",
"params": {},
"headers": {
"content-type": "application/json"
},
"body": "{{#toJson}}ctx.payload.summary{{/toJson}}"
}
}
}
}
这是我启动它时的响应:
{
"watch_id": "_inlined_",
"node": "QUApyNq4S5GyhHF-CuNjfg",
"state": "executed",
"status": {
"state": {
"active": true,
"timestamp": "2019-10-21T08:40:39.802Z"
},
"last_checked": "2019-10-21T08:40:39.802Z",
"last_met_condition": "2019-10-21T08:40:39.802Z",
"actions": {
"MS_TEAMS_PORT443": {
"ack": {
"timestamp": "2019-10-21T08:40:39.802Z",
"state": "awaits_successful_execution"
},
"last_execution": {
"timestamp": "2019-10-21T08:40:39.802Z",
"successful": false,
"reason": "received [400] status code"
}
}
},
"execution_state": "executed",
"version": -1
},
"trigger_event": {
"type": "manual",
"triggered_time": "2019-10-21T08:40:39.802Z",
"manual": {
"schedule": {
"scheduled_time": "2019-10-21T08:40:39.802Z"
}
}
},
"input": {
"simple": {
"summary": "Test Nom",
"text": "test"
}
},
"condition": {
"always": {}
},
"metadata": {
"name": "testJsonALaMano",
"xpack": {
"type": "json"
}
},
"result": {
"execution_time": "2019-10-21T08:40:39.802Z",
"execution_duration": 125,
"input": {
"type": "simple",
"status": "success",
"payload": {
"summary": "Test Nom",
"text": "test"
}
},
"condition": {
"type": "always",
"status": "success",
"met": true
},
"actions": [
{
"id": "MS_TEAMS_PORT443",
"type": "webhook",
"status": "failure",
"reason": "received [400] status code",
"webhook": {
"request": {
"host": "outlook.office.com",
"port": 443,
"scheme": "https",
"method": "post",
"path": "/webhook/XYZ",
"headers": {
"content-type": "application/json"
},
"body": "Test Nom"
},
"response": {
"status": 400,
"headers": {
"date": [
"Mon, 21 Oct 2019 08:40:38 GMT"
],
"content-length": [
"49"
],
"expires": [
"-1"
],
"x-beserver": [
"VI1PR07MB5053"
],
"x-aspnet-version": [
"4.0.30319"
],
"x-proxy-backendserverstatus": [
"400"
],
"x-cafeserver": [
"VE1PR03CA0023.EURPRD03.PROD.OUTLOOK.COM"
],
"x-calculatedbetarget": [
"VI1PR07MB5053.eurprd07.prod.outlook.com"
],
"request-id": [
"6d651f70-74b5-4010-a2a6-662666fa9985"
],
"pragma": [
"no-cache"
],
"x-msedge-ref": [
"Ref A: C6E8A3DCFF9541DD95D63FD71ACD695C Ref B: PAR02EDGE0513 Ref C: 2019-10-21T08:40:39Z"
],
"x-feserver": [
"VE1PR03CA0023"
],
"x-powered-by": [
"ASP.NET"
],
"x-backendhttpstatus": [
"400"
],
"content-type": [
"text/plain; charset=utf-8"
],
"cache-control": [
"no-cache"
]
},
"body": "Bad payload received by generic incoming webhook."
}
}
}
]
},
"messages": []
}
答案 0 :(得分:0)
错误的身体陈述。需要在正文中发送文字。改变你的身体像这样
"body": "{\"text\": \"{{ctx.payload.summary}}\"}"
答案 1 :(得分:0)
source
是您的朋友,在这里:
"body": {
"source": {
"text" : "Test Nom"
}
}