Slack.files.upload always give an error no_file_data

(Adam Jackson) #1

Running the command

st2 action execute slack.files.upload filename=/tmp/tantor_final.png token=“xoxb-redacted” channels="#tools_stackstorm_test" filetype="image/png"

give me an error

stderr: "st2.actions.python.SlackAction: ERROR Failed to perform action files.upload: {“ok”:false,“error”:“no_file_data”}

I am trying to send a binary to slack. The only issue I can see is that in headers[‘Content-Type’] = ‘application/x-www-form-urlencoded’ and maybe it should be multipart/form-data. I have tried a number of naming combinations, but always get “no_file_data”

thanks for any assistance

(Jinping) #2

File contents viamultipart/form-data. If omitting this parameter, you must submitcontent.

(Adam Jackson) #3

I did read the api and was trying to use the “file” option. Are you saying you must use the content option? Is it possible just to specify a local filename with the file option in stackstorm … possibly because it appears application/x-www-form-urlencoded is hard-coded as the default for Content-Type.

Thanks for your reply

(Jinping) #4

Yes, application/x-www-form-urlencoded is hard coded in and maybe you can modify slack.files.upload action to accept content-type' as input.