user3107343
user3107343

Reputation: 2299

Why is Twilio not sending sms?

I tried send a sms via the Twilio Api. But Twilio does not send to me any sms messages. What is wrong?

Reference https://www.twilio.com/docs/api/rest/sending-sms

My code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twilio;
namespace SMS

{
class Program
{
    static void Main(string[] args)
    {
        string AccountSid = "myAccountSid";
        string AuthToken = "{{ myAuthToken }}";
        var twilio = new TwilioRestClient(AccountSid, AuthToken);


        var sms = twilio.SendSmsMessage("myTwilioNumber", "myGsmNumber", "Test SMS", "");
        // var sms = twilio.SendSmsMessage("+14053350954", "+905xxyyyzzvv", "Test SMS", "");


        Console.WriteLine(sms.Sid);
    }
       }
         }

Upvotes: 1

Views: 5297

Answers (1)

Devin Rader
Devin Rader

Reputation: 10366

Twilio evangelist here.

Couple of ways to start diagnosing this.

First I'd suggest logging into your account and checking the message logs. If your app is actually successfully connecting to Twilio and telling it to send the text message, it will show up here.

If there are no messages in the log its likely that there is an error happening when you try to use the REST API to test Twilio to send the message. To check that you can look at the RestException property on your sms variable:

if (sms.RestException!=null)
{
    Debug.Writeline(sms.RestException.Message);
}

If the RestException parameter is null, then there is likely a transport error happening. Either your seeing a DNS resolve failure, or an HTTP request timeout.

Hope that helps.

Upvotes: 2

Related Questions