Hello all ,
first thanks for new webhook for API .
I have succesfully simple integration between zabbix and iTOP 2.7 , but one problem still exist. When create new entry in public log without new line , POST method to zabbix rest API working fine. When text include new line character , JSON structure is bad and POST failed .
Can you go to the object on which you updated the public log, then on the notifications tab and open the corresponding EventWebhook, then copy / paste us the complete "Payload" field (mind to ofuscate sensitive information)
Thanks,
Guillaume
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Guillaume ,
many thanks for quick response . In bellow two examples with message in one line and message with new line character.
This is OK :
Date
03.02.2022 15:22:45
Message
TEST - Sent
Final class
ActionWebhook
Webhook URL http://xxxxxxxx/zabbix/api_jsonrpc.php
Headers
Raw:
Content-Type: application/json
After preparation:
{
"jsonrpc": "2.0",
"method": "event.acknowledge",
"params": {
"eventids": "289077997",
"action": 6,
"message": "Ticket owner new message:This is test message."
},
"auth": "auth_key",
"id": 2
}
Response
{"jsonrpc":"2.0","result":{"eventids":[289077997]},"id":2}
And second try with text with new lines :
Date
03.02.2022 15:27:00
Message
TEST - Sent
Final class
ActionWebhook
Webhook URL http://xxxxxxxxxx/zabbix/api_jsonrpc.php
Headers
Raw:
Content-Type: application/json
After preparation:
{
"jsonrpc": "2.0",
"method": "event.acknowledge",
"params": {
"eventids": "289077997",
"action": 6,
"message": "Ticket owner new message:This
is
test
message."
},
"auth": "auth_key",
"id": 2
}
Response
{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}
Many thanks for help
Michal
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
New lines should encoded as "\n" instead of a real new line. I'm puzzled that the use of $this->head(public_log)$ does not encode correctly, especially as we used it for several app connections (iTop, Mantis, Slack, ...).
Are you using the "Payload" attribute or are you using a "Prepare payload callback"?
Guillaume
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think, the problem lies in the generic webhook action.
As it is meant to work with API that may not use REST/JSON, we leave the payload as is and don't encode its content into JSON format, which in your case is to convert new lines to "\n".
For the moment, the only workaround I see for you is to use the "prepare request" callback, but this will require you to create an extension in order to add you PHP method. 😕
PS: I'll check how we can fix it, but it might not be this week.
Cheers,
Guillaume
Last edit: Guillaume Lajarige 2022-02-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Guillaume ,
That's bad new for me , i'm not php programmer :-( . I really appreciate your time . I was looking for some examples for solution , but not luck.
If you have any fix/tip please let me know.
With best regards
Michal
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think I just fixed it, it's available on GitHub under this commit. The corresponding version will be available on iTop Hub around mid-March.
If you feel like beta-testing it, I'm attaching a development version of the extension on this post but you should NOT deploy it on production! Only versions from the Hub should be deployed on production.
In any case, we are grateful that you pointed this issue! Could you send me your full name and postal address via PM so we can send you thank-you stickers?
I'm very happy and many thanks for quick fix this issue . After applying this update on test installation existing webhook doesn't work , but when create new one all working flawlessly .
I'll send you PM with my address for stickers :-) .
With best regards
Michal
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
sorry for necroposting, put seems like the issue is still here...
when I send $this->head(public_log)$ with newlines inside, in payload
I always get the error :
Hello all ,
first thanks for new webhook for API .
I have succesfully simple integration between zabbix and iTOP 2.7 , but one problem still exist. When create new entry in public log without new line , POST method to zabbix rest API working fine. When text include new line character , JSON structure is bad and POST failed .
Example Payload :
{
"jsonrpc": "2.0",
"method": "event.acknowledge",
"params": {
"eventids": "$this->ext_ref$",
"action": 6,
"message": "Ticket owner $this->agent_name$ added test:$this->head(public_log)$"
},
"auth": "sessionkey_xxxx",
"id": 2
}
Any idea how to sent public_log with new lines to rest API ?
Many thanks for help .
Michal
Hello Michal,
Can you go to the object on which you updated the public log, then on the notifications tab and open the corresponding EventWebhook, then copy / paste us the complete "Payload" field (mind to ofuscate sensitive information)
Thanks,
Guillaume
Hello Guillaume ,
many thanks for quick response . In bellow two examples with message in one line and message with new line character.
This is OK :
Date
03.02.2022 15:22:45
Message
TEST - Sent
Final class
ActionWebhook
Webhook URL
http://xxxxxxxx/zabbix/api_jsonrpc.php
Headers
Raw:
Content-Type: application/json
After preparation:
Content-Type: application/json
Payload
Raw:
{
"jsonrpc": "2.0",
"method": "event.acknowledge",
"params": {
"eventids": "$this->ext_ref$",
"action": 6,
"message": "Ticket owner $this->agent_name$ new message:$this->head(public_log)$"
},
"auth": "auth_key",
"id": 2
}
After preparation:
{
"jsonrpc": "2.0",
"method": "event.acknowledge",
"params": {
"eventids": "289077997",
"action": 6,
"message": "Ticket owner new message:This is test message."
},
"auth": "auth_key",
"id": 2
}
Response
{"jsonrpc":"2.0","result":{"eventids":[289077997]},"id":2}
And second try with text with new lines :
Date
03.02.2022 15:27:00
Message
TEST - Sent
Final class
ActionWebhook
Webhook URL
http://xxxxxxxxxx/zabbix/api_jsonrpc.php
Headers
Raw:
Content-Type: application/json
After preparation:
Content-Type: application/json
Payload
Raw:
{
"jsonrpc": "2.0",
"method": "event.acknowledge",
"params": {
"eventids": "$this->ext_ref$",
"action": 6,
"message": "Ticket owner $this->agent_name$ new message:$this->head(public_log)$"
},
"auth": "auth_key",
"id": 2
}
After preparation:
{
"jsonrpc": "2.0",
"method": "event.acknowledge",
"params": {
"eventids": "289077997",
"action": 6,
"message": "Ticket owner new message:This
is
test
message."
},
"auth": "auth_key",
"id": 2
}
Response
{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}
Many thanks for help
Michal
Hello Michal,
New lines should encoded as "\n" instead of a real new line. I'm puzzled that the use of
$this->head(public_log)$
does not encode correctly, especially as we used it for several app connections (iTop, Mantis, Slack, ...).Are you using the "Payload" attribute or are you using a "Prepare payload callback"?
Guillaume
Hello Guillaume ,
i'm using just Payload attribute without any preparation of payload . It's possible to fix this problem ?
Thanks for help
With best regards
Michal
I think, the problem lies in the generic webhook action.
As it is meant to work with API that may not use REST/JSON, we leave the payload as is and don't encode its content into JSON format, which in your case is to convert new lines to "\n".
For the moment, the only workaround I see for you is to use the "prepare request" callback, but this will require you to create an extension in order to add you PHP method. 😕
PS: I'll check how we can fix it, but it might not be this week.
Cheers,
Guillaume
Last edit: Guillaume Lajarige 2022-02-07
Hello Guillaume ,
That's bad new for me , i'm not php programmer :-( . I really appreciate your time . I was looking for some examples for solution , but not luck.
If you have any fix/tip please let me know.
With best regards
Michal
Hello Michal,
I think I just fixed it, it's available on GitHub under this commit. The corresponding version will be available on iTop Hub around mid-March.
If you feel like beta-testing it, I'm attaching a development version of the extension on this post but you should NOT deploy it on production! Only versions from the Hub should be deployed on production.
In any case, we are grateful that you pointed this issue! Could you send me your full name and postal address via PM so we can send you thank-you stickers?
Cheers,
Guillaume
Hello Guillaume .
I'm very happy and many thanks for quick fix this issue . After applying this update on test installation existing webhook doesn't work , but when create new one all working flawlessly .
I'll send you PM with my address for stickers :-) .
With best regards
Michal
Great! Thanks for the feedback ✌
Have a nice day,
Guillaume
Hello,
could any one share with me how to configure itop with zabbix
thanks
One of the questions is already: do you want to send data from iTop to Zabbix, or the other way around?
For one of my customers, I added some extra functionality to the publicly available example somewhere on a Zabbix repository of webhooks.
sorry for necroposting, put seems like the issue is still here...
when I send $this->head(public_log)$ with newlines inside, in payload
I always get the error :
the whole error from log
Last edit: Alexey 2024-10-10