0

I have a following JSON file:

{
  "blocks": [
    {
      "type": "section",
      "text": {
        "type": "mrkdwn",
        "text": "Success: ondrejdolezal93's workflow (<https://circleci.com/api/v1.1/project/github/integromat/docker-db-updater/628|build>) in <https://app.circleci.com/pipelines/github/integromat/docker-db-updater%7Cintegromat/docker-db-updater> (<https://app.circleci.com/pipelines/github/integromat/docker-db-updater?branch=main%7Cmain>)\n- Fix update version (<https://github.com/integromat/docker-db-updater/commit/9a5b8d61a5c79dabbb2a47bb68b33748034986aa%7C9a5b8d6> by ondrejdolezal93)"
      }
    }
  ]
}

I am trying to send a message using Slack webhook with use of curl.

My command is like following:

curl -X POST -H 'Content-type: application/json' --data @message.json $SLACK_WEBHOOK_URL

The reply from curl is: no_text

Please, what am I doing wrong? JSON is formatted according to Slack API documentation.

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
user465180
  • 1
  • 1
  • 1

1 Answers1

1

In the Slack API documentation, it clearly says that if you send an JSON-encoded body, you will have to transmit your API token in an Authorization HTTP header. You are not doing this.

An example curl query is provided in the documentation (modified by indenting it, replacing the in-line JSON document by a reference to a file, and quoting the URL):

curl -X POST \
    -H 'Authorization: Bearer xoxb-1234-56789abcdefghijklmnop' \
    -H 'Content-type: application/json' \
    --data @message.json \
    'https://slack.com/api/chat.postMessage'

See the API documentation here: https://api.slack.com/web

Kusalananda
  • 320,670
  • 36
  • 633
  • 936