Ivan Bukata
Ivan Bukata

Reputation: 41

slack send message [ERROR] missing required field: channel

I am trying to test sending message to channel via bot (App, to be exact.)

My query in Postman: https://slack.com/api/chat.postMessage/ (there is token in headers) and body {"channel":"XXX","text":"I hope the tour went well, Mr. Wonka."}

But as result { "ok": false, "error": "invalid_arguments", "response_metadata": { "messages": [ "[ERROR] missing required field: channel" ] } }

Upvotes: 4

Views: 8501

Answers (4)

Merouane T.
Merouane T.

Reputation: 876

For myself, I was getting this because I was calling

POST https://slack.com/api/chat.postMessage/

The issue is in the last /. So the correct call is:

POST https://slack.com/api/chat.postMessage

EXTRA:

Here are my headers:

{
        'Content-Type': 'application/json',
        'charset': 'utf-8',
        'Authorization': 'Bearer {YOUR_BOT_TOKEN_INSIDE_WITHOUT_CURLY_BRACKETS}'
}

and my body (make sure to put the # before the name of the channel).

{
        'test': 'YOUR_TEXT_MESSAGE_IN_HERE',
        'channel': '#{YOUR_CHANNEL_NAME_WITHOUT_CURLY_BRACKETS}'
}

Upvotes: 1

Luc Bloom
Luc Bloom

Reputation: 1243

I had to set

content-type: "application/json; charset=utf-8"

The charset mattered.

Upvotes: 2

Oscar Rodriguez
Oscar Rodriguez

Reputation: 115

I had the same issue and my problem was that I was doing GET instead of POST. Now it works for me.

Upvotes: 8

Loc Nguyen
Loc Nguyen

Reputation: 26

Please check your content-type header. It should be "application/json" instead of "plain/text"

Upvotes: 1

Related Questions