I'm trying to send curl POST like this. (It's for Slack Webhook)
curl -X POST --data-urlencode "payload={\"username\": \"name\", \"text\": \"Some alert! <https://some.alert.url/|Click Here.>\"}" https://some.channel.url
It Says
The filename, directory name, or volume label syntax is incorrect.
Including "<", "|" throws this error. Tried setting variable, "\<", and so on...
How could I send this url properly?
CodePudding user response:
Either use single quotes that disable interpretation of unescaped shell special chars inside
curl -X POST --data-urlencode 'payload={"username": "name", "text": "Some alert! <https://some.alert.url/|Click Here.>"}' https://some.channel.url
Or also escape the special chars <
and >
curl -X POST --data-urlencode "payload={\"username\": \"name\", \"text\": \"Some alert! \<https://some.alert.url/|Click Here.\>\"}" https://some.channel.url
|
may also require escaping \|
.
CodePudding user response:
Answering myself.
I'm running this on Windows cmd. So I should not use "" but "^" for the escape character.
curl -X POST --data-urlencode "payload={\"username\": \"name\", \"text\": \"Some alert! ^<https://some.alert.url/|Click Here.^>\"}" https://some.channel.url
This works fine.