添加Studio Flow后Twilio REST Client发SMS报“Upgrade Required”错误
I’ve run into this exact error a few times when working with Twilio Studio and the REST API together, so let’s break down what’s likely going on and how to fix it:
Common Causes & Fixes
1. TLS Version Mismatch (Most Likely Culprit)
Twilio requires all API requests to use TLS 1.2 or higher, and while newer versions of the Twilio NuGet package should enforce this by default, older .NET Framework projects (especially those targeting 4.5 or lower) might not have TLS 1.2 enabled globally.
Add this line of code before you initialize the Twilio client or send your message:
' Force TLS 1.2/1.3 for Twilio requests System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 Or System.Net.SecurityProtocolType.Tls13
This ensures your app uses the correct TLS version that Twilio expects.
2. Verify Your Number’s Configuration in Twilio Console
When you link a phone number to a Studio Flow, double-check that the number isn’t restricted from sending outbound SMS:
- Go to your Twilio Console > Phone Numbers > Manage > Active Numbers
- Select the number you’re using in your code
- Under "Capabilities", confirm that SMS is enabled (it should show a green checkmark)
- Studio Flows only handle inbound messages/routing, but if you accidentally changed any number permissions during setup, that could block outbound sends.
3. Validate Twilio Credentials & Environment
It’s easy to accidentally tweak your credentials after setting up Studio Flow (especially if you’re testing with trial vs production accounts):
- Debug or log your
Credentials.TwilioFixityNewNumberFormatted, account SID, and auth token to confirm they match exactly what’s in your Twilio Console - Ensure you’re not using trial credentials in a production environment, or vice versa.
4. Test the API Directly (Bypass the NuGet Package)
To rule out issues with the Twilio library, test sending an SMS via raw API request:
- Use a tool like Postman to send a POST request to
https://api.twilio.com/2010-04-01/Accounts/{YourAccountSid}/Messages.json - Add form-data parameters:
Body(your message),From(your Twilio number),To(recipient number) - Use Basic Auth with your Account SID as the username and Auth Token as the password.
If this request succeeds, the problem is with how your app is using the NuGet package. If it fails, check your Twilio Console’s Monitor > Logs for detailed error details (Twilio usually logs the exact reason for failed requests here, even if there’s no dashboard notification).
5. Check Your Project’s .NET Framework Version
If you’re targeting .NET Framework 4.5 or earlier, it doesn’t support TLS 1.2 by default. Upgrade your project’s target framework to 4.6.1 or higher (in Visual Studio: Project Properties > Application > Target framework) to get native TLS 1.2 support.
Modified Code Example
Here’s how your code should look with the TLS fix added:
' Ensure TLS 1.2/1.3 is enabled first System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 Or System.Net.SecurityProtocolType.Tls13 Dim message = MessageResource.Create( body:=strBody, from:=New Twilio.Types.PhoneNumber(Credentials.TwilioFixityNewNumberFormatted), [to]:=New Twilio.Types.PhoneNumber(strFormattedNumber) ) Return message.Sid
If none of these steps work, check the Twilio Console logs for the failed request—there’s usually a more specific error code (like 426) that will point you to the exact issue.
内容的提问来源于stack exchange,提问作者A. Niese

