API plugin_output encoded input?

Good morning,
we are using for TRAPs snmptt. To push the trap in icinga we have a script which sends all important informations to the API.

/usr/bin/curl -s -X “POST” --cacert ‘$ICINGA2_CA_PATH’ -u ‘$ICINGA2_CURL_USERNAME:$ICINGA2_CURL_PASSWORD’ -H “Accept: application/json” -H “Content-Type: application/json; charset=utf-8” ‘https://$ICINGA2_CURL_URL/v1/actions/process-check-result?service=$icingaHostname!$icingaServicename&type=Service’ -d ‘{“exit_status”:$icingaServerity,“plugin_output”:“$icingaServiceOutput”,“check_source”:“$ICINGA2_SAT_FQDN”}’

But sometimes the Trap sends informations with special chars like single or double quotes.
This is often a big problem, because the API call will not work.
At the moment i replace in the script every quote. Is there a possibilty to ecode the “plugin_output” and the ICINGA Web will decode this?

Regards
Sascha

Only backslash, " and control codes have to be escaped in JSON.

1 Like