Maru
Maru

Reputation: 25

404 error while searching for twilio available phone number

I'm using Twilio trial account to know the compatibility of twilio with our project, I've tried to search for Twilio phone number using NodeJS API but, it is throwing 404 error for all the locations every time. Is it the problem with trial account or code.

Here is my code

var accountSid = '[My AccountSid]'; 
var authToken = '[My authToken]'; 
 
//require the Twilio module and create a REST client 
var client = require('../lib')('ACCOUNT_SID', 'AUTH_TOKEN');
 
client.availablePhoneNumbers('US').mobile.get({  
}, function(err, data) { 
    if(data){
    data.incomingPhoneNumbers.forEach(function(number) { 
	 console.log(number.PhoneNumber); 
	}); 
    }else{
        console.log(err);
    }
}); 

Upvotes: 1

Views: 1685

Answers (1)

philnash
philnash

Reputation: 73100

Twilio developer evangelist here.

We don't actually have a distinction between mobile and local numbers in the US, since the number format is the same and all numbers are voice and SMS capable.

So, I'd just use .local instead of .mobile.

Let me know if that helps.

[EDIT]

I used the following code and it returned and printed a list of US local numbers:

var twilio = require("twilio");
var client = new twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);

client.availablePhoneNumbers('US').local.get({},
  function(err, data) { 
    console.log(data);
  }
)

Upvotes: 4

Related Questions