使用twilio python api调用时出错

使用twilio python api调用时出错,python,twilio,twilio-api,twilio-python,Python,Twilio,Twilio Api,Twilio Python,尝试使用twilio python api进行调用时出现此错误: Jacob-Mac-mini:downloads kovyjacob$ python3 twilio_call.py Traceback (most recent call last): File "/Users/kovyjacob/Downloads/twilio_call.py", line 11, in <module> call = client.calls.create(

尝试使用twilio python api进行调用时出现此错误:

Jacob-Mac-mini:downloads kovyjacob$ python3 twilio_call.py
Traceback (most recent call last):
  File "/Users/kovyjacob/Downloads/twilio_call.py", line 11, in <module>
    call = client.calls.create(
  File "/Users/kovyjacob/Library/Python/3.9/lib/python/site-packages/twilio/rest/api/v2010/account/call/__init__.py", line 141, in create
    payload = self._version.create(method='POST', uri=self._uri, data=data, )
  File "/Users/kovyjacob/Library/Python/3.9/lib/python/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/['AC766eaf7ef8d79de658756223cee446df']/Calls.json

Twilio returned the following information:

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

More information may be available here:

https://www.twilio.com/docs/errors/20404
Jacob Mac mini:下载kovyjacob$python3 twilio_call.py
回溯(最近一次呼叫最后一次):
文件“/Users/kovyjacob/Downloads/twilio_call.py”,第11行,在
call=client.calls.create(
文件“/Users/kovyjacob/Library/Python/3.9/lib/Python/site-packages/twilio/rest/api/v2010/account/call/__-init__.py”,第141行,在create中
payload=self.\u version.create(method='POST',uri=self.\u uri,data=data,)
文件“/Users/kovyjacob/Library/Python/3.9/lib/Python/site-packages/twilio/base/version.py”,第205行,在create中
引发self.exception(方法、uri、响应“无法创建记录”)
twilio.base.exceptions.TwilioRestException:
HTTP错误您的请求是:
POST/Accounts/['AC766eaf7ef8d79de658756223cee446df']/Calls.json
Twilio返回了以下信息:
无法创建记录:未找到请求的资源/2010-04-01/Accounts/['AC766eaf7ef8d79de658756223cee446df']/Calls.json
有关更多信息,请访问:
https://www.twilio.com/docs/errors/20404
我检查了链接,但a)我不确定到底是什么问题,b)它没有说明如何修复它

代码如下:

from twilio.rest import Client


# Your Account Sid and Auth Token from twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ['AC766eaf7ef8d79de658756223cee446df']
auth_token = ['74ef4743a7a9a748cxxxxxxxxxxxxxxx']
client = Client(account_sid, auth_token)

call = client.calls.create(
                        twiml='<Response><Say>Ahoy, World!</Say></Response>',
                        to='+14372341004',
                        from_='+14243560675'
                    )

print(call.sid)
从twilio.rest导入客户端
#来自twilio.com/console的帐户Sid和身份验证令牌
#并设置环境变量。看见http://twil.io/secure
账户_sid=['AC766eaf7ef8d79de658756223cee446df']
认证令牌=['74EF4743A7A9A748CXXXXXXXXXX']
客户端=客户端(帐户sid、身份验证令牌)
call=client.calls.create(
twiml='Ahoy,世界!',
to='+14372341004',
from_uz='+14243560675'
)
打印(call.sid)

帐户sid
身份验证令牌
应作为字符串传递,而不是包含字符串的数组

编辑代码以:

account_sid = 'AC766eaf7ef8d79de658756223cee446df'
auth_token = '74ef4743a7a9a748cxxxxxxxxxxxxxxx'

我将代码添加到question@KovyJacob,编辑回答:非常感谢!