c# – Twilio TwilioRestClient does not contain a definition for SendSmsMessage

c# – Twilio TwilioRestClient does not contain a definition for SendSmsMessage

Twilio developer evangelist here.

You say you have installed version 5.4.0 of the Twilio C# library. However I think you are looking at the version 4.x documentation as SendSmsMessage is an old method.

You now need to use the new MessageResource object. Please check out the example below or the documentation for sending messages here.

using System;
using System.Threading.Tasks;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Your Account SID from twilio.com/console
            var accountSid = AC81ebfe1c0b5c6769aa5d746121284056;
            // Your Auth Token from twilio.com/console
            var authToken = auth_token;   

            TwilioClient.Init(accountSid, authToken);

            var message = MessageResource.Create(
                to: new PhoneNumber(+15558675309),
                from: new PhoneNumber(+15017250604),
                body: Hello from C#);

            Console.WriteLine(message.Sid);
            Console.Write(Press any key to continue.);
            Console.ReadKey();
        }
    }
}

It may be the case that Twilio.Asp.Mvc 5.1 hasnt got its version constraints correct and expects the version 4 library. So you may just need to pin Twilio back to version 4.7.2 and it will start working again.

Let me know if this helps at all.

Assuming your error message is a copy-and-paste from the original, then it looks like a simple typo in the method name: you have SenSmsMessage, missing the d from Send.

c# – Twilio TwilioRestClient does not contain a definition for SendSmsMessage

Leave a Reply

Your email address will not be published.