Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to successfully upload a file via Slack API

Tags:

slack

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.

like image 661
jasonw75 Avatar asked Oct 15 '22 05:10

jasonw75


2 Answers

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

like image 183
Xav Avatar answered Oct 21 '22 06:10

Xav


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)

like image 44
HenonoaH Avatar answered Oct 21 '22 06:10

HenonoaH