# Watcher: Invalid JSON

**URL:** <https://discuss.elastic.co/t/watcher-invalid-json/106855>\
**Category:** Elasticsearch\
**Created:** [November 8, 2017, 11:34am UTC](https://discuss.elastic.co/t/watcher-invalid-json/106855 "2017-11-08T11:34:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mruthyu](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mruthyu](https://discuss.elastic.co/u/mruthyu)\
**Post date:** [November 8, 2017, 11:34am UTC](https://discuss.elastic.co/t/watcher-invalid-json/106855/1 "2017-11-08T11:34:59Z")

</div>

I am trying to create the following watcher and seeing **Invalid JSON** error message and not able to create the watcher.

```
{
  "trigger": {
    "schedule": {
      "interval": "200m"
    }
  },
  "input": {
    "search": {
      "request": {
        "body": {
          "size": 0,
          "query": {
            "match_all": {}
          }
        },
        "indices": [
          "*"
        ]
      }
    }
  },
  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gte": 10
      }
    }
  },
 "actions" : {
  "create_github_issue" : {
    "webhook" : {
      "method" : "POST",
      "url" : "https://api.github.com/repos/<owner>/<repo>/issues",
      "body" : "{
        \"title\": \"Found errors in 'contact.html'\",
        \"body\": \"Found {{ctx.payload.hits.total}} errors in the last 5 minutes\",
        \"assignee\": \"web-admin\",
        \"labels\": [\"bug\", \"sev2\"]
      }",
      "auth" : {
        "basic" : {
          "username" : "username", 
          "password" : "password"
        }
      }
    }
  }
}
}
```

---

<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:** [November 8, 2017, 11:51am UTC](https://discuss.elastic.co/t/watcher-invalid-json/106855/2 "2017-11-08T11:51:05Z")

</div>

The full exception would be tremendously useful in this case instead of just the error mesasge.

Two things

- First it looks as if there is an additional closing bracket at the end
- Second, the `body` field needs to be in a single line, JSON does not support multi line elements.

hope this helps, otherwise please provide more information.

Thanks.

--Alex

---

<div class="post-metadata">

**Author:** ![mruthyu](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mruthyu](https://discuss.elastic.co/u/mruthyu)\
**Post date:** [November 8, 2017, 12:16pm UTC](https://discuss.elastic.co/t/watcher-invalid-json/106855/3 "2017-11-08T12:16:59Z")

</div>

Thanks Alex for your quick response. It was the second one which was causing the issue.  
May be the example in this link [https://www.elastic.co/guide/en/x-pack/current/actions-webhook.html](https://www.elastic.co/guide/en/x-pack/current/actions-webhook.html)  
needs to be updated to have the body in single line. Have referred the example from here.

---

<div class="post-metadata">

**Author:** ![Burak\_Seyhan](https://avatars.discourse-cdn.com/v4/letter/b/e99b99/32.png) [@Burak\_Seyhan](https://discuss.elastic.co/u/Burak_Seyhan)\
**Post date:** [November 8, 2017, 12:33pm UTC](https://discuss.elastic.co/t/watcher-invalid-json/106855/4 "2017-11-08T12:33:16Z")

</div>

> [@mruthyu](#):
>
> {  
> "trigger": {  
> "schedule": {  
> "interval": "200m"  
> }  
> },  
> "input": {  
> "search": {  
> "request": {  
> "body": {  
> "size": 0,  
> "query": {  
> "match\_all": {}  
> }  
> },  
> "indices": [  
> "\*"  
> ]  
> }  
> }  
> },  
> "condition": {  
> "compare": {  
> "ctx.payload.hits.total": {  
> "gte": 10  
> }  
> }  
> },  
> "actions" : {  
> "create\_github\_issue" : {  
> "webhook" : {  
> "method" : "POST",  
> "url" : "[https://api.github.com/repos/&lt;owner&gt;/&lt;repo&gt;/issues](https://api.github.com/repos/&lt;owner&gt;/&lt;repo&gt;/issues)",  
> "body" : "{  
> "title": "Found errors in 'contact.html'",  
> "body": "Found {{ctx.payload.hits.total}} errors in the last 5 minutes",  
> "assignee": "web-admin",  
> "labels": ["bug", "sev2"]  
> }",  
> "auth" : {  
> "basic" : {  
> "username" : "username",  
> "password" : "password"  
> }  
> }  
> }  
> }  
> }  
> }

Check your json file from here [https://jsonformatter.curiousconcept.com/](https://jsonformatter.curiousconcept.com/)

---

<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:** [November 10, 2017, 9:11am UTC](https://discuss.elastic.co/t/watcher-invalid-json/106855/5 "2017-11-10T09:11:02Z")

</div>

indeed, that's a documentation issue, that I just fixed.

Thanks a lot for pointing it out!

---

<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:** [December 8, 2017, 9:11am UTC](https://discuss.elastic.co/t/watcher-invalid-json/106855/6 "2017-12-08T09:11:35Z")

</div>

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