Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Incoming webhooks - multiline in payload data ends with Server Error

Open tarabanton opened this issue 10 years ago • 1 comments

Your Rocket.Chat version: 0.44 We are using https://github.com/ericoc/zabbix-slack-alertscript/blob/master/slack.sh for integrating Zabbix with Rocket.Chat. Previously we were using slack. Everything worked fine. Now, when we send payload to Rocket.Chat server with multiline contents server responds with Server Error Message is not appearing in corresponding channel

Integrations ➔ Incoming WebHook.info Post integration
SyntaxError: Unexpected token 

    at Object.parse (native)
    at Object.Restivus.auth.user (packages/rocketchat_integrations/server/api/api.coffee:54:24)
    at Route.share.Route.Route._authenticate (packages/nimble_restivus/lib/route.coffee:182:35)
    at Route.share.Route.Route._authAccepted (packages/nimble_restivus/lib/route.coffee:169:8)
    at Route.share.Route.Route._callEndpoint (packages/nimble_restivus/lib/route.coffee:147:9)
    at packages/nimble_restivus/lib/route.coffee:59:33
    at packages/simple_json-routes/json-routes.js:76:1

Our payload sent with curl is as follows:

curl -m 5 --data-urlencode 'payload={"channel": "#zabbix", "username": "zabbix", "text": "PROBLEM: Server  - User problem (user.problem[key]:Some text: 
 (3185)text: on: new line 10/10)", "icon_emoji": ":negative_squared_cross_mark:"}' https://<domain>/hooks/<token>

tarabanton avatar Oct 27 '16 09:10 tarabanton

Well, problem was solved on script side. It seems that Rocket.Chat doesn't convert newlines to \\n Added something along that to script:

text=${3//$'\n'/\\n}
message="${subject}: ${text}"

tarabanton avatar Oct 28 '16 10:10 tarabanton