slacker icon indicating copy to clipboard operation
slacker copied to clipboard

Missing Request Mime types

Open N-Schaef opened this issue 4 years ago • 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.

N-Schaef avatar May 06 '20 06:05 N-Schaef

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 avatar Jun 01 '20 16:06 mortanius-1

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

mortanius-1 avatar Jun 08 '20 11:06 mortanius-1