mruthyu  
                (MJay)
               
                 
              
                  
                    November 8, 2017, 11:34am
                   
                   
              1 
               
             
            
              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"
        }
      }
    }
  }
}
} 
             
            
               
               
               
            
            
           
          
            
              
                spinscale  
                (Alexander Reelsen)
               
              
                  
                    November 8, 2017, 11:51am
                   
                   
              2 
               
             
            
              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
             
            
               
               
              1 Like 
            
            
           
          
            
              
                mruthyu  
                (MJay)
               
              
                  
                    November 8, 2017, 12:16pm
                   
                   
              3 
               
             
            
              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  
needs to be updated to have the body in single line. Have referred the example from here.
             
            
               
               
               
            
            
           
          
            
            
              
 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/<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" 
} 
} 
} 
} 
} 
}
 
 
Check your json file from here https://jsonformatter.curiousconcept.com/ 
             
            
               
               
               
            
            
           
          
            
              
                spinscale  
                (Alexander Reelsen)
               
              
                  
                    November 10, 2017,  9:11am
                   
                   
              5 
               
             
            
              indeed, that's a documentation issue, that I just fixed.
Thanks a lot for pointing it out!
             
            
               
               
               
            
            
           
          
            
              
                system  
                (system)
                  Closed 
               
              
                  
                    December 8, 2017,  9:11am
                   
                   
              6 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.