os / slacker

Full-featured Python interface for the Slack API
Apache License 2.0
1.6k stars 245 forks source link

Missing Request Mime types #168

Open N-Schaef opened 4 years ago

N-Schaef commented 4 years ago

Hello,

the slack API requires that requests set the correct mime types, like application/json. This library does not yet do so. (See for example Incoming Webhook)

The slack API does not (yet) enforce this. But the slack compatible mattermost API recently started doing so, which means this library does not work with mattermost anymore.

mortanius-1 commented 4 years ago

Hey just a heads up the fix is relatively trivial to implement if you get the time to implement and push upstream please review lines:

https://github.com/os/slacker/blob/ec39f344583ce4e415648159b060eb52793b6c97/slacker/__init__.py#L1182-L1183

Set the headers in the post request: headers={'content-type': 'application/json'}, example change:

return requests.post(self.url, data=json.dumps(data),
                             timeout=self.timeout, proxies=self.proxies, 
                             headers={'content-type': 'application/json'})
mortanius-1 commented 4 years ago

Hey @N-Schaef Mattermost have release a new version: 5.23.1 that fixes this issue.

Detail: Modified the mime check, such that we now require Content-Type to be set in the request header. This change was unintentional and led to breaking changes.

See issue: https://mattermost.atlassian.net/plugins/servlet/mobile?originPath=%2Fbrowse%2FMM-25677#issue/MM-25677