A. Niese
A. Niese

Reputation: 409

Twilio REST Client stops working after adding Studio Flow?

I am using Twilio REST client in Visual Studio 2017. After adding a Studio Flow for a simple SMS autoresponder, I am no longer able to use the Twilio REST API to send a SMS message from my ASP.net app.

The error message is "Upgrade Required"

at Twilio.Clients.TwilioRestClient.ProcessReponse(Reponse response)
at Twilio.Rest.Api.V2010.Account.MessageResource.Create(CreateMessageOptions options, ITwilioRestClient client)
at...

I already tried upgrading the Twilio REST API helper library NuGet package to latest, version 5.28.0.

The error occurs on this basic SMS sending code that used to work.

Dim message = MessageResource.Create(body:=strBody, from:=New Twilio.Types.PhoneNumber(Credentials.TwilioFixityNewNumberFormatted), [to]:=New Twilio.Types.PhoneNumber(strFormattedNumber))
Return message.Sid

There are no error messages or notifications in my Twilio account that something is wrong or needed. Has anyone experienced something like this?

Upvotes: 4

Views: 1935

Answers (2)

Pathoschild
Pathoschild

Reputation: 4706

Twilio returns Upgrade Required when you use an old TLS version. Setting the version directly using ServicePointManager.SecurityProtocol does fix it, but it's not a good idea since it'll become outdated when a new TLS version is released. Instead, see Transport Layer Security (TLS) best practices with the .NET Framework for some reasons it may be selecting an older version.

In my case it was due to this line in Web.config:

<httpRuntime targetFramework="4.5" />

Setting it to the actual .NET Framework version I'm using fixed the Twilio error.

Upvotes: 2

A. Niese
A. Niese

Reputation: 409

It seems that modifying the Twilio project made it a "new" project subject to TLS 1.2 requirements that were just implemented on 3/28/19. The problem was solved by updating Windows and .NET to the latest updates, and explicitly enabling TLS 1.2 prior to accessing the Twilio REST API:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12   'Force TLS 1.2

Upvotes: 3

Related Questions