Curl to watcher webhook

I have a curl post operation which uses OTRS REST API to create tickets . I want to integrate the same using watcher webhook .

These are the parameters required to create a ticket in OTRS

{
"UserLogin" : "admin",
"Password" : "admin",
"Ticket" : {
"Title" : "test",
"CustomerUser" :"Customer1",
"Queue" : "Raw",
"State" : "New",
"Priority" : "1 very low"
},
"Article" : {
"CommunicationChannelID" : "1",
"Subject" : "Test",
"Body" : "This is a test10 ",
"ContentType" : "text/plain; charset=utf8"
}

}

How do I use the same params inside a webhook ? I tried this

"my_webhook": {
"webhook": {
"scheme": "http",
"host": "example.com",
"port": 80,
"method": "post",
"path": "/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket",
"headers": {"Content-Type": "application/json" },
"body": {
"UserLogin" : "admin",
"Password" : "admin",
"Ticket" : {
"Title" : "test",
"CustomerUser" :"Customer1",
"Queue" : "Raw",
"State" : "New",
"Priority" : "1 very low"
},
"Article" : {
"CommunicationChannelID" : "1",
"Subject" : "Test",
"Body" : "This is a test10 ",
"ContentType" : "text/plain; charset=utf8"
}
}
}
}

But I am getting errors like this

Watcher: [illegal_argument_exception] [script] unknown field [UserLogin], parser not found

Pinging @spinscale for his thoughts on this one

the body field needs to be a string right now.

However you can create a proper payload via a script in the transform of the webhook action, and then use the toJson mustache helper, which creates JSON. There is an example in the docs https://www.elastic.co/guide/en/x-pack/6.2/actions-webhook.html

1 Like

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