我尝试使用Webhooks将 POST 请求发送到我的闲暇频道,但无济于事。
无论我做什么,它总是返回一个不好的请求。
是否可以在不使用Webhook的情况下发送 POST 请求到松弛状态?
编辑:我正在使用的代码
import json
import urllib.request
#import botocore.requests as requests
def lambda_handler(event,context):
webhook=event['webhook']
#response = urllib.request.urlopen(message)
#print(response)
slack_URL = 'https://hooks.slack.com/services/mywebhookurl'
# req = urllib.request.Request(SLACK_URL,json.dumps(webhook).encode('utf-8'))
json=webhook
json=json.encode('utf-8')
headers={'Content-Type': 'application/json'}
#urllib.request.add_data(data)
req = urllib.request.Request(slack_URL,json,headers)
response = urllib.request.urlopen(req)