Уважаемые коллеги, помогите пожалуйста!!!
На zabbix 5,2 работал данный Webhook. На версии Zabbix 6.2 перестал
Сначала была такая ошибка "
Я исправил " request = new CurlHttpRequest()," на " request = new HttpRequest(),"
Теперь другая ошибка "
И тут я уже не могу понять.
Прошу помочь!
На zabbix 5,2 работал данный Webhook. На версии Zabbix 6.2 перестал
Code:
var ICQ = {
token: null,
to: null,
message: null,
sendMessage: function() {
var response,
request = new CurlHttpRequest(),
url = 'https://api.icq.net/bot/v1/messages/sendText?token=' + ICQ.token + '&chatId=' + ICQ.to + '&text=' + ICQ.message;
request.AddHeader('Content-Type: application/json');
// Remove replace() function if you want to see the exposed token in the log file.
Zabbix.Log(4, '[ICQ Webhook] URL: ' + url.replace(ICQ.token, '<TOKEN>'));
Zabbix.Log(4, '[ICQ Webhook] chat(message): ' + ICQ.to + '('+ ICQ.message +')');
response = request.Post(encodeURI(url));
Zabbix.Log(4, '[ICQ Webhook] HTTP code: ' + request.Status());
try {
response = JSON.parse(response);
}
catch (error) {
response = null;
}
if (request.Status() !== 200 || typeof response.ok !== 'boolean' || response.ok !== true) {
if (typeof response.description === 'string') {
throw response.description;
}
else {
throw 'Unknown error. Check debug log for more information.'
}
}
}
}
try {
var params = JSON.parse(value);
if (typeof params.Token === 'undefined') {
throw 'Incorrect value is given for parameter "Token": parameter is missing';
}
ICQ.token = params.Token;
ICQ.to = params.To;
ICQ.message = params.Subject + '\n' + params.Message;
ICQ.sendMessage();
return 'OK';
}
catch (error) {
Zabbix.Log(4, '[ICQ Webhook] notification failed: ' + error);
throw 'Sending failed: ' + error + '.';
}
- Sending failed: ReferenceError: identifier 'CurlHttpRequest' undefined.
Я исправил " request = new CurlHttpRequest()," на " request = new HttpRequest(),"
Теперь другая ошибка "
- Sending failed: TypeError: undefined not callable (property 'AddHeader' of [object Object]).
И тут я уже не могу понять.
Прошу помочь!

Comment