0

I replaced the phone number in to = " " with a variable and I am getting an HTTP Error message.

phoneNumber = +14403943924

message = client.messages.create(
                to= phoneNumber, 
                from_="+14397829146",
                body= message)

HTTP Error Your request was:

POST /Accounts/AC5eadecae45ea157bc833c458a3cf0349/Messages.json

Twilio returned the following information:

Unable to create record: The 'To' number 32+14403943924 is not a valid phone number.

Not sure why it adds a 32 in front of my variable above.

palantir
  • 11
  • 3

1 Answers1

0

Twilio developer evangelist here.

I'm able to use your code above with my own phone number, Twilio number, and Twilio credentials and get a text message back/without getting your error. That being said, something I usually do is I wrap phone numbers in quotation marks--so maybe try changing phoneNumber = +14403943924 to phoneNumber = "+14403943924" (even though I was able to get the code to work without the quotations.)

Let me know if this helps at all!

lizziepika
  • 3,231
  • 1
  • 14
  • 23
  • Hi! It is still adding a 32 at the beginning of the phone number I want to send to. I even print(phoneNumber) and receive +14403943924... which is accurate. When I run with twilio I receive the error above (Unable to create record: The 'To' number 32+14403943924 is not a valid phone number.) There is nothing in the code that would suggest that the number 32 should appear before my phoneNumber variable. Is this on twilios end? – palantir Jun 21 '21 at 20:40