title: Elasticsearch watcher and Microsoft Teams webhook
body: <p>I have been trying desperately for 5 days to create an elasticsearch watcher alert that sends a notification on an incoming webhook teams. However, the answer I receive is "Bad payload received by generic incoming webhook". I do not understand why it does not work.</p>
  
  <pre><code>{
    "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}}"
        }
      }
    }
  }
  </code></pre>
  
  <p>And this is the response when I launch it: </p>
  
  <pre><code>{
    "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": []
  }
  </code></pre>