I'm trying to send sms from Twilio in ASP .NET but it throws this:
The From phone number +XXXXXX is not a valid, SMS-capable inbound phone number or short code for your account
My code looks like this:
[HttpPost]
[Route("sms")]
public HttpResponseMessage SendMessage()
{
var AccountSid = "XXXXXXXXXXXX";
var AccountToken = "XXXXXXXXXXXX";
TwilioClient.Init(AccountSid, AccountToken);
var to = new PhoneNumber("+XXXXXXXXX");
var from = new PhoneNumber("+XXXXXXXXXX");
var message = MessageResource.Create(to: to, from: from, body: "Hi from me");
return Request.CreateResponse(HttpStatusCode.OK,message.Sid);
}
My error looks like this:
{
"Message": "An error has occurred.",
"ExceptionMessage": "The From phone number +XXXXXX is not a valid, SMS-capable inbound phone number or short code for your account.",
"ExceptionType": "Twilio.Exceptions.ApiException",
}
var from = new PhoneNumber("+XXXXXXXXXX");
tovar from = new PhoneNumber("+YYYYYYYYYY");
where+YYYYYYYYYY
is a number you purchased from Twilio. – Alex Baban