Hello everyone
We use generic webhooks on Incidents to inform our staff. Since we upgraded to itop 3 from 2.7, the webhook extension doesn't work as expected.
We integrate the field 'description' of an Incident in our payload like this:
{ "title": "$this->title$", "description": "$this->description$", "team_id": "$this->team_id$", "team_name": "$this->team_name$", }
Everything works properly if the description field doesn't contain new lines, however as soon as a new line is included, the "Wrong JSON format for input" error is triggered.
The error log then shows this:
2024-09-05 16:25:49 | Error | 1 | Webhook Action failed: Wrong JSON format for input | notifications ||| array ( 'action_class' => 'ActionWebhook', 'action_id' => '352', 'action_name' => 'external api call', 'payload' => '{ "title": "$this->title$", "description": "$this->description$", "team_id": "$this->team_id$", "team_name": "$this->team_name$", }', 'json_last_error' => 3, 'json_last_error_msg' => 'Control character error, possibly incorrectly encoded', )
I've also tried the unreleased versions of the extension, 1.3.2, 1.3.3 where some json parsing fixes were applied, but nothing works.
Thanks for your help in advance
We fixed it for now by replacing "\r\n" and "\n" in the ApplyParamsToJson method. But it seems that the problem lies deeper within the itop code.
Log in to post a comment.
Hello everyone
We use generic webhooks on Incidents to inform our staff. Since we upgraded to itop 3 from 2.7, the webhook extension doesn't work as expected.
We integrate the field 'description' of an Incident in our payload like this:
{
"title": "$this->title$",
"description": "$this->description$",
"team_id": "$this->team_id$",
"team_name": "$this->team_name$",
}
Everything works properly if the description field doesn't contain new lines, however as soon as a new line is included, the "Wrong JSON format for input" error is triggered.
The error log then shows this:
2024-09-05 16:25:49 | Error | 1 | Webhook Action failed: Wrong JSON format for input | notifications |||
array (
'action_class' => 'ActionWebhook',
'action_id' => '352',
'action_name' => 'external api call',
'payload' => '{
"title": "$this->title$",
"description": "$this->description$",
"team_id": "$this->team_id$",
"team_name": "$this->team_name$",
}',
'json_last_error' => 3,
'json_last_error_msg' => 'Control character error, possibly incorrectly encoded',
)
I've also tried the unreleased versions of the extension, 1.3.2, 1.3.3 where some json parsing fixes were applied, but nothing works.
Thanks for your help in advance
We fixed it for now by replacing "\r\n" and "\n" in the ApplyParamsToJson method. But it seems that the problem lies deeper within the itop code.