Reputation: 681
How do I post an ampersand via the Slack hook with curl
?
$ curl -4 -X POST --data 'payload={"text": "amp;"}' https://hooks.slack.com/services/aaa/bbb/ccc
ok
$ curl -4 -X POST --data 'payload={"text": "&"}'
https://hooks.slack.com/services/aaa/bbb/ccc
invalid_payload
$ curl -4 -X POST --data 'payload={"text": "<>"}' https://hooks.slack.com/services/aaa/bbb/ccc
ok
$ curl -4 -X POST --data 'payload={"text": "<&>"}'
https://hooks.slack.com/services/aaa/bbb/ccc
invalid_payload
I am really trying to post something like Message <https://nagios?host=foo&type=1|link here>
but I can not for the life of me get that &
accepted.
Upvotes: 1
Views: 557
Reputation: 681
A colleague figured out that the workaround is to post %26
:
curl -4 -X POST --data 'payload={"text": "%26"}' https://hooks.slack.com/services/aaa/bbb/ccc
ok
This renders an &
in Slack and can be used to construct a URL.
Reference: https://github.com/ansible/ansible-modules-extras/issues/2734
Upvotes: 1