'How to send json data in cURL
I am trying to post rich text as json data to slack channel using post request but cURL treating data as url and requesting it, how to avoid this situation
here is my request looks like
SLACK_DATA='{\"text\": \"Danny Torrence left a 1 star review for your property.\",\"blocks\": [{\"type\": \"section\",\"text\": {\"type\": \"mrkdwn\",\"text\": \"Danny Torrence left the following review for your property:\"}},{\"type\": \"section\",\"block_id\": \"section567\",\"text\": {\"type\": \"mrkdwn\",\"text\": \"<https://example.com|Overlook Hotel> \n :star: \n Doors had too many axe holes, guest in room 237 was far too rowdy, whole place felt stuck in the 1920s.\"},\"accessory\": {\"type\": \"image\",\"image_url\": \"https://is5-ssl.mzstatic.com/image/thumb/Purple3/v4/d3/72/5c/d3725c8f-c642-5d69-1904-aa36e4297885/source/256x256bb.jpg\",\"alt_text\": \"Haunted hotel image\"}},{\"type\": \"section\",\"block_id\": \"section789\",\"fields\": [{\"type\": \"mrkdwn\",\"text\": \"*Average Rating*\n1.0\"}]}]}'
curl -X POST -H 'Content-type: application/json' --data \'$SLACK_DATA\' https://hooks.slack.com/services/XXXXXXXXX/XXXXXXX/XXxXXXXXXXXXXXXX
I am getting the following output which seems it requesting data treating it as a URL
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 26 0 15 100 11 71 52 --:--:-- --:--:-- --:--:-- 123
invalid_payload % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: \"Danny
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: Torrence
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: left
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (6) Could not resolve host: a
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|