【问题标题】:Getting /Accounts/['ACCOUNT_SID]/Messages.json not found error while working with Twilio使用 Twilio 时出现 /Accounts/['ACCOUNT_SID]/Messages.json 未找到错误
【发布时间】:2021-05-02 04:55:09
【问题描述】:

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

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 都是正确的。我该如何处理?

【问题讨论】:

    标签: python twilio twilio-api


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-17
      • 1970-01-01
      • 1970-01-01
      • 2021-04-14
      • 2021-09-11
      • 1970-01-01
      • 2016-04-21
      • 2018-03-17
      相关资源
      最近更新 更多