I’m having trouble determining the correct API endpoint and the correct API fields to use to upload a file to a channel.
I have seen issue #1693 on Github for a similar question and a few posts about it on here. The only answers provided are links to the Javascript and the Go driver. I tried reverse engineering those drivers to figure out what fields are required to do this to no avail.
I’ve also read in the documentation on the MM website that the new API Version is directly compatiable with the Slack API. I’ve tried to port this code over, no luck.
I think I am almost there. Could anyone give me a hand? I am using Python 2.x with the requests module.
When I try to post the file in a channel it shows up with the name “files” instead of the filename. It seems like the filename isn’t making it to the server at all. Any ideas? This is the code I’m using to send my upload request.
files = {
'files': fileBytes,
'filename': filePath
}
data = {
'channel_id': channelId,
}
res = requests.post(
self.server + url,
headers=headers,
data=data,
files=files,
verify=False
)
return res
@braddaniels It looks like you’re using the Python requests library, correct? I’m not 100% on the format they expect for files, but it looks like you should be using