微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 Twilio 时获取 /Accounts/['ACCOUNT_SID]/Messages.json not found 错误

如何解决使用 Twilio 时获取 /Accounts/['ACCOUNT_SID]/Messages.json not found 错误

搜索了类似的问题,但找不到满意的答案。 这是我用来将消息从我的 Twilio 验证号码发送到我注册的手机号码的 python 片段:

account_sid = ['AC02ba1e07c83130f76679f2f334160fba']
auth_token = ['*******************************']
client = Client(account_sid,auth_token)

message = client.messages \
            .create(
                body=sent,from_='my_twilio_mobile_number',to='my_reg_mobile_number'
            )
print(message.sid)

执行后,我收到以下错误

Traceback (most recent call last):
  File "/Users/ameeteshsharma/Documents/covax/avail.py",line 59,in <module>
  message = client.messages \
  File "/usr/local/lib/python3.9/site-packages/twilio/rest/api/v2010/account/message/__init__.py",line 88,in create
  payload = self._version.create(method='POST',uri=self._uri,data=data,)
  File "/usr/local/lib/python3.9/site-packages/twilio/base/version.py",line 205,in create
  raise self.exception(method,uri,response,'Unable to create record')
  twilio.base.exceptions.TwilioRestException: 
 HTTP Error Your request was:

 POST /Accounts/['AC02ba1e07c83130f76679f2f334160fba']/Messages.json

 Twilio returned the following information:

 Unable to create record: The requested resource /2010-04-01/Accounts/['AC02ba1e07c83130f76679f2f334160fba']/Messages.json was not found

 More information may be available here:

 https://www.twilio.com/docs/errors/20404

我尝试查看上述文档,但找不到合理的解决方案。 account_sid 和 auth_token 都是正确的。我该如何处理?

解决方法

我认为错误在于您将 account_sidauth_token 都声明为 list,它们应该是 string

account_sid = 'AC02ba1e07c83130f76679f2f334160fba'
auth_token = '*******************************'
client = Client(account_sid,auth_token)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。