Twilio’s .NET helper library accepts its own HTTP transport abstraction. Its SystemNetHttpClient adapter lets that transport use a System.Net.Http.HttpClient configured by the application.

var proxy = new System.Net.WebProxy(
    "http://proxy.example.net:8080")
{
    Credentials = proxyCredentials
};

var handler = new System.Net.Http.HttpClientHandler
{
    Proxy = proxy,
    UseProxy = true,
    AllowAutoRedirect = false
};

var systemHttp = new System.Net.Http.HttpClient(handler);
var transport = new Twilio.Http.SystemNetHttpClient(systemHttp);
var twilioClient = new Twilio.Clients.TwilioRestClient(
    accountSid, authToken, httpClient: transport);

The application supplies proxyCredentials, such as an appropriate NetworkCredential, and its existing Twilio accountSid and authToken. Remove the Credentials initializer when the intermediary needs no account. An HTTP endpoint selected from the HTTP proxy list is another candidate for that unauthenticated route, subject to the network policy for this application.

Pass twilioClient to the helper operation’s client parameter. Otherwise that operation may use a separately configured default client.

AllowAutoRedirect is disabled here to retain the SDK adapter’s default behavior when it creates its own underlying client. Supplying your own HttpClient makes its handler settings your responsibility.

Keep systemHttp alive for the associated workload and dispose it when that workload ends. A new handler around every SDK request creates a new connection pool instead of reusing the configured transport.

Allakkat attuumassuteqartut