Uploading a file to Slack has no response in chat

Viewed 88

I'm trying to send some txt data with this code

    my_file = {'file' : ('/home/suomi/_data.txt', open('/home/suomi/_data.txt', 'r'), 'txt')}

    payload={
        "filename":"aaaa.txt", 
        "token":API_BOT, 
        "channel":'*my_user_id*',
        }

    x = requests.post("https://slack.com/api/files.upload", params=payload, files=my_file)

    print(x)
    print(x.json())

getting this response


<Response [200]>
{'ok': True, 'file': {'id': '*private_id*', 'created': 1603941396, 'timestamp': 1603941396, 'name': 'aaaa.txt', 'title': 'aaaa', 'mimetype': 'text/plain', 'filetype': 'text', 'pretty_type': 'pretty text', 'user': '*my private user_id*', 'editable': True, 'size': 18145, 'mode': 'snippet', 'is_external': False, 'external_type': '', 'is_public': False, 'public_url_shared': False, 'display_as_bot': False, 'username': '', 'url_private': '*private url_link*', 'url_private_download': '*private url_link*', 'permalink': '*private url_link*', 'permalink_public': '*private url_link*', 'edit_link': '*private url_link*', 'preview': "*somedata*", 'preview_highlight': '<div class="CodeMirror cm-s-default CodeMirrorServer" oncopy="if(event.clipboardData){event.clipboardData.setData(\'text/plain\',window.getSelection().toString().replace(/\\u200b/g,\'\'));event.preventDefault();event.stopPropagation();}">\n<div class="CodeMirror-code">\n<div><pre>*somedata*</pre></div>\n<div><pre></pre></div>\n<div><pre>*************************************</pre></div>\n<div><pre></pre></div>\n</div>\n</div>\n', 'lines': 131, 'lines_more': 126, 'preview_is_truncated': True, 'comments_count': 0, 'is_starred': False, 'shares': {}, 'channels': [], 'groups': [], 'ims': [], 'has_rich_preview': False}}

values inside ** are replaced due to privacy.

But I'm not getting a response from my app - I have enabled right permissions and I can send normal text messages.

files:write, channels:history, channels:read, chat:write, groups:history

BTW. I'm trying to send a file to user, not channel

0 Answers
Related