------------------------------------------------------------------------------ To reply, visit https://hellosplat.com/s/beanbag/tickets/4642/ ------------------------------------------------------------------------------
New ticket #4642 by splatter2 For Beanbag, Inc. > Review Board Status: New Tags: Priority:Medium, Type:Defect ------------------------------------------------------------------------------ Slack notification fails due to incorrect Content-Type header ============================================================================== # What version of Djblets are you using? 1.0.2 # Which module(s) have the problem? rbintegrations # What steps will reproduce the problem? 1. Create a Slack notification 2. Submit a new review request. # What is the expected output? What do you see instead? Slack notification should be successful, but fails. If logging is turned on, a stackrace will appear in the logs. # What version of Python and Django? Python 2.7, DJango 1.11.6 # Please provide any additional information below. Capturing network traffic using tcpdump revealed that the `Content-Type` header was being set incorrectly. The `Content-Type` header is set to `application/x-www-form-urlencoded`, but the body is json. Therefore, the request is refused by Slack (or Mattermost in my case). The culprit is at line [189](https://github.com/reviewboard/rbintegrations/blob/master/rbintegrations/slack/integration.py#L189) of `integration.py`. urllib2 defaults to form data when posting. The fix is very simple. Change the line to read: ``` urlopen(Request(webhook_url, 'payload='+json.dumps(payload))) ``` Another option is to do this instead, as explained [here](https://stackoverflow.com/a/7606288): ``` json_data = json.dumps(payload) urlopen(Request(webhook_url, json_data, {'Content-Type': 'application/json', 'Content-Length': len(data)})) ``` ------------------------------------------------------------------------------ -- You received this message because you are subscribed to the Google Groups "reviewboard-issues" group. To unsubscribe from this group and stop receiving emails from it, send an email to reviewboard-issues+unsubscr...@googlegroups.com. To post to this group, send email to reviewboard-issues@googlegroups.com. Visit this group at https://groups.google.com/group/reviewboard-issues. For more options, visit https://groups.google.com/d/optout.