这是我的代码片段,其中我将有效负载发送到一个松弛的webhook:
dictoftitle = {i: posts_to_print[i] for i in range(0, len(posts_to_print))}
response = requests.post(web_hook_url, data=json.dumps(dictoftitle))
if response.status_code != 200:
raise ValueError('Request to slack returned an error %s, the response is:\n%s '%
(response.status_code, response.text) )以下是有效负载的外观:
print(dictoftitle)
{0: 'When girls are the shero of the story', 1: 'Simplified global game management: Introducing Game Servers', 2: 'Google Cloud named a leader in the Forrester Wave for Public Cloud Development and Infrastructure Platforms', 3: "Modernizing Twitter's ad engagement analytics platform", 4: 'Protect users in your apps with
multi-factor authentication', 5: 'Postponing Google Cloud Next ’20: Digital Connect', 6: 'Not just for HTTP anymore: gRPC comes to Cloud Run', 7: 'Data processing just got easier with Apps Script’s new V8 runtime', 8: 'G Suite Pro Tips: Declutter your inbox with Gmail filters', 9: 'How EBSCO delivers dynamic research services with Apigee', 10: 'Finding a problem at the bottom of the Google stack', 11: 'Best practices for Chrome Enterprise admins to enable a remote workforce', 12: 'Modern analytics made easy with new Redshift, S3 migration tools', 13: 'Local SSDs + VMs = love at first (tera)byte', 14: '재택근무 시 업무 수행과 관련된 8가
지 도움말', 15: '使用 G Suite 居家办公的八大妙招', 16: '善用 8 大秘訣,確保在家工作時的工作效率', 17: '8 tips untuk menyelesaikan pekerjaan saat bekerja dari jarak jauh', 18: '8 mẹo để hoàn thành công việc khi làm việc tại nhà', 19: 'เคลดลบ 8 ข้อเพ่อการทำงานจากบ้านอย่างมประสทธภาพ'}我在发送有效负载时遇到错误:
Traceback (most recent call last):
File "test3.py", line 83, in <module>
raise ValueError('Request to slack returned an error %s, the response is:\n%s '% (response.status_code, response.text) )
ValueError: Request to slack returned an error 400, the response is:
missing_text_or_fallback_or_attachments 你知道是什么导致了这个问题吗?
发布于 2020-03-26 12:32:24
您正在尝试将通用的Slack传入webhook与发送自定义有效负载的服务一起使用,对吗?您需要将它们的有效负载转换为松弛传入webhooks (https://api.slack.com/messaging/composing)所接受的格式。我希望这是有意义的。如果您对此有任何进一步的问题,请让我们知道。
https://stackoverflow.com/questions/60840397
复制相似问题