Search code examples
curlslackslack-api

Slack Upload : Error while trying to upload using Curl


I am trying to upload a local file using curl command which I got to know about from here but while trying to run the command, It is not working and throwing error:

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

Command I am running is:

curl -F file=testsend.txt -F channels=#channel -F token='token' -F filetype=post https://slack.com/api/files.upload

Solution

  • According to the error message you got, the access token you are using does not seam to be valid. Please double-check that you are using a valid access token, should look something like this:

    -F token='xoxo-123456789-123456789'
    

    I am assuming you did not use 'token' as access token. That would obviously not work.

    to get an access token you want to create a Slack app and install it to your workplace (see documentation here), or you can get a legacy token for test purposes.

    Also make sure your access token has the needed permissions for uploading files, e.g. files:write:user