松弛块+;发送响应不';不能在python中工作,即使在异步时也不行-仅在CURL中 将块发送到松弛-正确显示松弛状态 单击按钮,我将获得交互式事件webhook webhook将200 OK返回给slack,而不是在将异步POST调度到响应\u url之前 webhook函数返回200 ack后,返回消息将发布到response\u url Slack响应404到响应\u url 当卷曲到python之外时,同样的响应URL也会起作用
我不明白为什么slack会用404拒绝发布的返回消息,而在python之外的curl中使用相同的响应时,url会起作用 我的webhook处理器:松弛块+;发送响应不';不能在python中工作,即使在异步时也不行-仅在CURL中 将块发送到松弛-正确显示松弛状态 单击按钮,我将获得交互式事件webhook webhook将200 OK返回给slack,而不是在将异步POST调度到响应\u url之前 webhook函数返回200 ack后,返回消息将发布到response\u url Slack响应404到响应\u url 当卷曲到python之外时,同样的响应URL也会起作用,python,django,slack-api,Python,Django,Slack Api,我不明白为什么slack会用404拒绝发布的返回消息,而在python之外的curl中使用相同的响应时,url会起作用 我的webhook处理器: def slack_webhook(request): json_dict = json.loads(request.body.decode('utf-8')) token = json_dict['token'] if 'token' in json_dict else None message = json_dict['m
def slack_webhook(request):
json_dict = json.loads(request.body.decode('utf-8'))
token = json_dict['token'] if 'token' in json_dict else None
message = json_dict['message'] if 'message' in json_dict else None
trigger_id = json_dict['trigger_id'] if 'trigger_id' in json_dict else None
response_url = json_dict['response_url'] if 'response_url' in json_dict else None
actions = json_dict['actions'] if 'actions' in json_dict else None
for action in actions:
print(f"** received action {action['action_id']}")
print(f"** response_url: {response_url}")
print(f"** trigger_id: {trigger_id}")
payload = {
"replace_original": True,
"text": "Success!",
}
# async via Celery...
send_slack_interactive_response.delay(response_url, payload, trigger_id)
return HttpResponse(status=200)
发送
@app.task(bind=True, retry_kwargs={'max_retries': 10, 'countdown': 5})
def send_slack_interactive_response(self, response_url, payload, trigger_id):
print(f"** -> response_url: {response_url}")
print(f"** -> trigger_id: {trigger_id}")
if response_url and payload and trigger_id:
headers = {"Content-Type": "application/json"}
payload['trigger_id'] = trigger_id
print(json.dumps(payload))
r = requests.post(response_url, data=payload, headers=headers)
print(r.__dict__)
该函数在404中失败。但是,当我使用响应\u url
,触发\u id
并使用命令行curl
创建完全相同的POST时,它就工作了
我做错了什么?只是对代码的一个注释:您可以执行
token=json\u dict.get(“token”,None)
,这样可以节省大量代码
关于你的问题:
json
而不是数据
。)只需对您的代码做一点注释:您可以执行
token=json\u dict.get(“token”,None)
,这样可以节省大量代码
关于你的问题:
json
而不是数据
。)