Transform script via Create Watcher API

Hi!

I'm trying to put new watcher via Create Watcher API

curl -X PUT "localhost:9200/_watcher/watch/my-watch?pretty" -H 'Content-Type: application/json' -d'
{
...
  "actions" {
    "problem": {
      "transform": {
        "script": "return [ 'webhook_body': webhook_body ]"
      }
    }
  }
...
}
'

I get the response

{
  "error" : {
    "root_cause" : [
      {
        "type" : "script_exception",
        "reason" : "compile error",
        "script_stack" : [
          "return [ webhook_body : webhook_bo ...",
          "         ^---- HERE"
        ],
        "script" : "return [ webhook_body : webhook_body ]",
        "lang" : "painless",
        "position" : {
          "offset" : 9,
          "start" : 0,
          "end" : 34
        }
      }
    ],
    "type" : "script_exception",
    "reason" : "compile error",
    "script_stack" : [
      "return [ webhook_body : webhook_bo ...",
      "         ^---- HERE"
    ],
    "script" : "return [ webhook_body : webhook_body ]",
    "lang" : "painless",
    "position" : {
      "offset" : 9,
      "start" : 0,
      "end" : 34
    },
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "cannot resolve symbol [webhook_body]"
    }
  },
  "status" : 400
}

What coud be a problem?

And the main question - How can I put watcher with multiline transform scripts via API?

Well

after changing quotes to unicode characters it works

[ \u0027webhook_body\u0027 : webhook_body ]

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