jasonw75
jasonw75

Reputation: 53

Unable to successfully upload a file via Slack API

I'm unable to successfully upload a file even using Slacks file.upload tester mechanism here: https://api.slack.com/methods/files.upload

I've applied a Slack app token, channel name, and chosen a file, but get the following result:

{
    "ok": false,
    "error": "missing_scope",
    "needed": "files:write:user",
    "provided": "identify,incoming-webhook"
}

I then created a new app, and ensured that files: write was in scope (it wasn't in the previous app). Now, I get a different error:

 {
    "ok": false,
    "error": "not_in_channel"
}

As a test to confirm that the channel name was ok, I subsequently tried a nonexistent channel name, and the error indicated 'channel_not_found', so the channel name I used should be valid.

Upvotes: 5

Views: 3477

Answers (4)

Akin Ozen
Akin Ozen

Reputation: 11

This solved my issue : https://stackoverflow.com/a/78933760/19252746

If you add the bot, have scopes etc. this would solve your problem. Slacks official doc is wrong i believe. This answer uses POST instead of PUT.

Upvotes: 0

tiredqa_18
tiredqa_18

Reputation: 331

You just need to invite the app that you created into the slack channel. Example:

@AppBot

Upvotes: 0

HenonoaH
HenonoaH

Reputation: 399

Before posting a message, reacting to any message or uploading files you need to open a conversation with the channel. You can also do it programmatically and achieve this with the help of API (https://api.slack.com/methods/conversations.open)

Upvotes: 1

Xav
Xav

Reputation: 51

I had the same issue and fixed it by adding the Slack app to the channel

I guess there are many ways to add it; I just opened the corresponding channel I was trying to "files.upload" to, and clicked the "Add an app" link at the really top of the channel history: screenshot

Upvotes: 4

Related Questions