twilio/twilio-python — Issue #36: Phone numbers not updating after purchase
Author: granteagon
Created: 2011-11-07 23:55:11+00:00
State: open

I'm having trouble getting changes to purchased phone numbers to save to twilio. I can purchase the numbers and send sms just fine. After purchasing, I check the site and the sms url is not showing and sending a message from my phone to the number does not execute the callback. I get no error from the purchase/update.

Version I'm using: 3.3.2

Code I'm running:
from django.conf import settings
client = TwilioRestClient(settings.TWILIO_ACCOUNT_SID, settings.TWILIO_ACCOUNT_TOKEN)
def buy_phone_number(area_code):
numbers = client.phone_numbers.search(area_code=area_code)
if numbers:
new_number = numbers[0].purchase()
new_number.sms_application_sid = settings.TWILIO_APP_SID
new_number.sms_url = settings.TWILIO_SMS_URL
new_number.update()

If I run the code from the docs, then I get an error that indicates I invalid parameters have been passed.
http://readthedocs.org/docs/twilio-python/en/latest/usage/phone-numbers.html#changing-applications

Code I run:
def buy_phone_number(area_code):
numbers = client.phone_numbers.search(area_code=area_code)
if numbers:
new_number = numbers[0].purchase()
number = client.phone_numbers.update(new_number.sid, application="AP123")

Error I get:
update() got an unexpected keyword argument 'application'
Also fails when I try:
number = client.phone_numbers.update(new_number.sid, sms_application_sid="AP123")
with error: update() got an unexpected keyword argument 'sms_application_sid'

The only way I was able to get the attributes I set to be reflected on twilio.com is by passing the kwargs to purchase().
Thanks to https://github.com/saebyn