Python 3.x 松弛400错误:“;回答是:缺少“文本”或“回退”或“附件”;

Python 3.x 松弛400错误:“;回答是:缺少“文本”或“回退”或“附件”;,python-3.x,webhooks,slack,slack-api,slack-commands,Python 3.x,Webhooks,Slack,Slack Api,Slack Commands,这是我向slack 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 return

这是我向slack 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    
回溯(最近一次呼叫最后一次):
文件“test3.py”,第83行,在
raise VALUERROR('松弛请求返回错误%s,响应为:\n%s'(response.status\u code,response.text))
ValueError:slack请求返回错误400,响应为:
缺少\u文本\u或\u回退\u或\u附件

你知道是什么导致了这个问题吗

您正在尝试将通用的Slack传入webhook与发送自定义负载的服务一起使用,对吗?您需要将它们的有效负载转换为传入webhooks()接受的格式。我希望这是有道理的。如果您对此有任何进一步的问题,请告诉我们。

您正在尝试将通用Slack传入webhook与发送自定义负载的服务一起使用,对吗?您需要将它们的有效负载转换为传入webhooks()接受的格式。我希望这是有道理的。如果您对此有任何进一步的问题,请告诉我们