Search code examples
curlslackslack-api

How to post csv file to slack using curl?


I am using the below curl command to post CSV file to slack. The command is executing successfully, but I am not able to see CSV file updating in slack. Can someone let me know what is the issue with below command ?

curl -s -F title='Batch status of XXXX ' -F initial_comment='Batch Status report XXXXX'  --form-string channels=xxxx-monitoring   -F [email protected] -F filename=etest.csv   -F token=xxxxx   https://xxxx.slack.com/archives/Cxxxxxx

Solution

  • I doubt the command es executing successfully. You just don't see any error message, because you are using the silent option (-s).

    The issue with your command is that you are not calling the correct API endpoint.

    For files.upload the correct endpoint is https://slack.com/api/files.upload (not https://xxxx.slack.com/archives/Cxxxxxx)

    This should work:

    curl -F title='Batch status of XXXX ' -F initial_comment='Batch Status report XXXXX'  --form-string channels=xxxx-monitoring   -F [email protected] -F filename=etest.csv   -F token=xxxxx   https://slack.com/api/files.upload