# How to pass body to endPoint using a watcher

**URL:** <https://discuss.elastic.co/t/how-to-pass-body-to-endpoint-using-a-watcher/162982>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [January 4, 2019, 3:46pm UTC](https://discuss.elastic.co/t/how-to-pass-body-to-endpoint-using-a-watcher/162982 "2019-01-04T15:46:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mdavi](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mdavi](https://discuss.elastic.co/u/mdavi)\
**Post date:** [January 4, 2019, 3:46pm UTC](https://discuss.elastic.co/t/how-to-pass-body-to-endpoint-using-a-watcher/162982/1 "2019-01-04T15:46:17Z")

</div>

Hi,

I'm trying to call a public endpoint ([p-log.herokuapp.com](http://p-log.herokuapp.com)), sending the json-body in the request, using a **sentinl watcher**  
The service **[p-log.herokuapp.com](http://p-log.herokuapp.com)** show me the request with headers but the body is always empty. Why???  
Here below the code of my watcher:

```
   {
  "actions": {
    "call_external_endPoint": {
      "webhook": {
        "method": "POST",
        "host": "p-log.herokuapp.com",
        "port": 80,
        "path": "/endpoint/",
        "params": {},
        "body": "{{#toJson}}ctx.payload{{/toJson}}",
        "headers": {
          "Content-type": "application/json"
        }
      }
    }
  },
  "input": {
    "search": {
      "request": {
        "index": [
          "logstash*"
        ],
        "body": {
          "size": 0,
          "query": {
            "bool": {
              "must": [
                {
                  "match": {
                    "fields.EnvironmentName": "Production"
                  }
                },
                {
                  "range": {
                    "@timestamp": {
                      "gte": "now-10d/d",
                      "lt": "now/d"
                    }
                  }
                }
              ]
            }
          },
          "aggs": {
            "Applications": {
              "terms": {
                "field": "fields.ApplicationName.raw"
              },
              "aggs": {
                "Level": {
                  "terms": {
                    "field": "level.raw"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "script": {
      "script": "payload.hits.total > 0"
    }
  },
  "trigger": {
    "schedule": {
      "later": "every 24 hours"
    }
  },
  "title": "TEST - Call External EndPoint",     
}

```

Could someone help me?  
Thanks.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [January 7, 2019, 9:42am UTC](https://discuss.elastic.co/t/how-to-pass-body-to-endpoint-using-a-watcher/162982/2 "2019-01-07T09:42:13Z")

</div>

The `script` condition never matches, thus the watch is never executed, as you need to use `ctx.payload.hits.total`.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [January 7, 2019, 9:42am UTC](https://discuss.elastic.co/t/how-to-pass-body-to-endpoint-using-a-watcher/162982/3 "2019-01-07T09:42:38Z")

</div>

oh, I just realized you are not talking about the alerting feature. You might have more success in the forums of the specific product, instead of asking here. Sorry for the confusion.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 4, 2019, 9:42am UTC](https://discuss.elastic.co/t/how-to-pass-body-to-endpoint-using-a-watcher/162982/4 "2019-02-04T09:42:40Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
