0

I'm trying to use the Requests library make a POST call to Slack using Python 3.4 on a Mac (OS X 10.10), like so:

url = 'https://slack.com/api/files.upload'
with open('File β.txt', 'rb') as file:
    r = requests.post(url, files={'file': file}, params={
        'token': api_token,
        'channels': channel
    })

But then I get a "no_file_data" response from Slack. If I use an ASCII "B" character instead of the unicode beta, then it works fine.

My file is UTF-8 encoded, and I have this line below my hashbang:

# -*- coding: UTF-8 -*-

Is this a problem with Slack, or something I'm doing wrong in Python?

Dov
  • 15,530
  • 13
  • 76
  • 177
  • What Python version are you using and what OS? It seems to me that this has nothing to do with requests or slack, but with your OS being able to handle unicode filenames. – jedwards Apr 11 '15 at 03:39
  • Thanks for updating with that information. Unfortunately OS X is not a platform I have access to to try to help, but [this](http://stackoverflow.com/questions/9757843/unicode-encoding-for-filesystem-in-mac-os-x-not-correct-in-python) or [this](http://nedbatchelder.com/blog/201106/filenames_with_accents.html) may help. – jedwards Apr 11 '15 at 18:09

1 Answers1

0

This turns out to be an issue with Slack's web API implementation, which doesn't support RFC 5987bis. I was helped along to this conclusion by some helpful members of the Requests team on a GitHub issue thread.

I'll update this answer once the bug is fixed.

Community
  • 1
  • 1
Dov
  • 15,530
  • 13
  • 76
  • 177