2

There are test numbers to which you can send SMS using my test credentials. They fake sending beautifully. But, attempting to use the lookup API also provided by Twilio, even if the intention is to retrieve information about the test number, will fail:

>>> from django.conf import settings
>>> from twilio.rest.lookups import TwilioLookupsClient
>>> account_sid = settings.TWILIO_ACCOUNT_SID
>>> auth_token = settings.TWILIO_AUTH_TOKEN
>>> client = TwilioLookupsClient(account_sid, auth_token)
>>> lookup_client.phone_numbers.get('+15005555009', include_carrier_info=True)
---------------------------------------------------------------------------
TwilioRestException                       Traceback (most recent call last)
<ipython-input-9-03718f1c0615> in <module>()
----> 1 client.phone_numbers.get('+15005555009', include_carrier_info=True)

...

TwilioRestException: 
HTTP Error Your request was:

GET https://lookups.twilio.com/v1/PhoneNumbers/+15005555009?Type=carrier

Twilio returned the following information:

Resource not accessible with Test Account Credentials

More information may be available here:

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

+15005555009 is the only phone number listed to emulate a landline, that is incapable of returning an SMS. I am expecting the API to return 'landline' for the carrier type for such a number. That link in the error message brings me to a page with no working test credentials.

How can I test the lookup API with the test credentials given?

Community
  • 1
  • 1
Brian
  • 7,394
  • 3
  • 25
  • 46

1 Answers1

4

I don't think you can use the lookup API with test credentials.

From https://www.twilio.com/docs/api/rest/test-credentials ...

"Supported Resources

Your test credentials can currently be used to interact with the following three resources:

  • Buying phone numbers: POST /2010-04-01/Accounts/{TestAccountSid}/IncomingPhoneNumbers

  • Sending SMS messages: POST /2010-04-01/Accounts/{TestAccountSid}/SMS/Messages

  • Making calls: POST /2010-04-01/Accounts/{TestAccountSid}/Calls

Requests to any other resource with test credentials will receive a 403 Forbidden response. In the future, we may enable these resources for testing as well."

Alex Baban
  • 11,312
  • 4
  • 30
  • 44