Feb-20-2018, 01:58 PM
(This post was last modified: Feb-20-2018, 02:04 PM by onenessboy.)
Hi,
tried as you suggested with requests.post instead of urllib2. following is the tracebak
and sorry while pasting i missed that ] which you have mentioned..
Traceback (most recent call last):
File "/home/user/script/ABSlack1.py", line 39, in <module>
slack_msg = json.loads(response)
File "/usr/lib64/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
This is what code change which i tried as per you suggestions
tried as you suggested with requests.post instead of urllib2. following is the tracebak
and sorry while pasting i missed that ] which you have mentioned..
Traceback (most recent call last):
File "/home/user/script/ABSlack1.py", line 39, in <module>
slack_msg = json.loads(response)
File "/usr/lib64/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
This is what code change which i tried as per you suggestions
slack_msg = json.loads(response) slack_msg['channel'] = SLACK_CHANNEL slack_json = json.dumps(slack_msg) #req = Request(HOOK_URL, slack_json) response = requests.post( webhook_url, data=slack_json, headers={'Content-Type': 'application/json'})