shrekDeep
shrekDeep

Reputation: 2328

Creating a twiML file while working with twilio and C#.net

I am working with twilio.com api in C#.net. C# code calls the phone number I have given:

            string accountSid = "AC5xxxxxxxxxfdb0cf485d52ce";
            string authToken = "57fxxxxxxxxx1xxx71a";
            var client = new TwilioRestClient(accountSid, authToken);
            var request = new CallListRequest();
            var callList = client.ListCalls(request);

            var options = new CallOptions();
            options.Url = "http://demo.twilio.com/docs/voice.xml";// 
            options.To = "+919876123456";
            options.From = "+15163425887";
            var call = client.InitiateOutboundCall(options);
            MessageBox.Show(call.Sid);

I call my phone through above given code, picking up the call connects me to the xml file (a twiML file) mentioned in options.Url and I listen the message and .mp3 file mentioned in voice.xml. Now I want to replace this xml file with my custom xml file placed in a server. For testing purpose I created the exact copy of voice.xml and placed it into my server. So I change the url property to:

options.Url="http://productionserver.com/voice.xml";

After making this change when I pick the phone, it says "Application error has occurred" and call ends.

Has anyone worked with twilio and experienced such problem ? Is there any step that I am missing other than just creating an xml file ?

Upvotes: 1

Views: 1373

Answers (1)

Devin Rader
Devin Rader

Reputation: 10366

Twilio evangelist here.

First I'd suggest checking to see if anything got logged in your App Monitor. I suspect you will see Twilio has logged a 500 error there.

If you are trying to serve the raw XML file from IIS, then your probably running into the issue that IIS won't serve an XML file from a POST request, which is the default HTTP Method Twilio uses to request the Url.

There are a couple of work-arounds for this:

  1. You can set the Method property on the CallOptions to GET which tells Twilio to make its request using the HTTP GET method OR
  2. Since this is static XML you are serving, you cold use http://twimlbin.com to host the TwiML

Hope that helps.

Upvotes: 2

Related Questions