Mix Master Mike
Mix Master Mike

Reputation: 1309

Slack (via Oauth) chat.postMessage Error, "channel_not_found", Even Though Channel Is Present

When I test out chat.postMessage using Slack's tester plus a legacy token everything works correctly as seen in the 1st screenshot below.

However, when I try a POST request via Postman using my oauth workspace access token a channel_not_found error gets kicked back even though I am using the same exact channel ID (C9FEK4T0D). The bottom screenshot shows my setup in Postman. Per Slack specs, I am placing my access tokens in the request's Authorization HTTP header.

What am I not including or doing incorrectly that's resulting in the error?

BTW, not sure if it matters but chat.postMessage gets invoked via a slash command.


chat.postMessage Test Screenshot:

chat.postMessage Test screenshot confirmation


Screenshot of POST request to chat.postMessage using request via Postman:

enter image description here

Upvotes: 0

Views: 3389

Answers (2)

Joshua
Joshua

Reputation: 1723

If you are using new Slack Bot Token Scopes, make sure that you are also using the Bot User OAuth Access Token and not the legacy user-based OAuth Access Token.

The OAuth Access Token will not fail immediately, but will always be restricted by the rights of the user who requested the app installation. This results in IMs between the bot user and other workspace users not being visible.

Upvotes: 0

Mix Master Mike
Mix Master Mike

Reputation: 1309

By moving the params to the body it resolved the issue. I was mixing params with a header which is a no no.

enter image description here

enter image description here

Upvotes: 1

Related Questions