0

I'm setting up masked calling. When I get the following TwiML response after calling the masked number, it isn't dialing the number that I'm specifying. It's just saying the number instead after saying the content of the say

Here is the TwiML

<?xml version="1.0" encoding="utf-8"?>
<Response>
  <Say>Your call will be charged blah blah.</Say>
  <Dial action="http://mywebsite.com/Call/CallComplete" callerId="+441XXXXX">
    <Number>+44795XXXXX</Number>
  </Dial>
</Response>

And here is the c#

public static string TwiMLDial(string maskedNumber, string to, string actionURL)
{
  var response = new Twilio.TwiML.VoiceResponse();
  response.Say("Your call will be charged blah blah.");

  var dial = new Twilio.TwiML.Dial(action: actionURL, callerId: maskedNumber);
  dial.Number(to);
  response.Dial(dial);
  return response.ToString();
}

I'm using c# .Net core. And have the following in my startup.cs which may be relevant:

services.AddMvc(config =>
            {
                // Add XML Content Negotiation
                config.RespectBrowserAcceptHeader = true;
                config.InputFormatters.Add(new XmlSerializerInputFormatter());
                config.OutputFormatters.Add(new XmlSerializerOutputFormatter());
            })
             .AddJsonOptions(options =>
             {
                 options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                 options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
             });
James
  • 4,146
  • 1
  • 20
  • 35

1 Answers1

1

Twilio developer evangelist here.

The issue is that your endpoint is returning the response with the type text/plain and Twilio takes that to mean, just read this out.

You need to set your response Content-Type to text/xml or application/xml.

I'm not a C# developer I'm afraid, but hopefully that points you in the right direction.

philnash
  • 70,667
  • 10
  • 60
  • 88