os/slacker

Missing Request Mime types

N-Schaef opened this issue · 2 comments

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.

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:

slacker/slacker/__init__.py

Lines 1182 to 1183 in ec39f34

return requests.post(self.url, data=json.dumps(data),
timeout=self.timeout, proxies=self.proxies)

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'})

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