try {
Zabbix.Log(4, 'dingding webhook script value='+value)
var result = {
'tags': {
'endpoint': 'ding'
}
},
params = JSON.parse(value),
req = new CurlHttpRequest(),
fields = {},
resp;
req.AddHeader('Content-Type: application/json');
fields.msgtype = params.msgtype;
fields.text = {
"content":params.content
};
resp = req.Post('https://oapi.dingtalk.com/robot/send?access_token=1163d78d7b8a324d2f5b284414da8e93560008689744495ab4ad3eae14bdd642',
JSON.stringify(fields)
);
if (req.Status() != 201) {
throw 'Response code: '+req.Status();
}
resp = JSON.parse(resp);
result.tags.issue_id = resp.id;
result.tags.issue_key = resp.key;
} catch (error) {
Zabbix.Log(4, 'jira issue creation failed json : '+JSON.stringify({"fields": fields}));
Zabbix.Log(4, 'jira issue creation failed : '+error);
result = {};
}
return JSON.stringify(result);