TwiML App unexpected call end: could not find declaration of 'response' element

I created a TwiML application and set the voice request URL in the web deployment of the ASP.NET-MVC action method: http://voiceapp-001-site1.myasp.net/voice

This action method is called when someone navigates to the URL above:

public ActionResult Voice() { Response.ContentType = "text/xml"; // put a phone number you've verified with Twilio to use as a caller ID number string callerId = Settings.TwilioNumber; // put your default Twilio Client name here, for when a phone number isn't given string number = "jenny"; // get the phone number from the page request parameters, if given if (Request["PhoneNumber"] != null) { number = Request["PhoneNumber"]; } // wrap the phone number or client name in the appropriate TwiML verb // by checking if the number given has only digits and format symbols string numberOrClient; var m = Regex.Match(number, @"^[\d\+\-\(\) ]+$"); if (m.Success) { numberOrClient = string.Format("<Number>{0}</Number>", number); } else { numberOrClient = string.Format("<Client>{0}</Client>", number); } ViewBag.CallerId = callerId; ViewBag.NumberOfClient = numberOrClient; return View(); } 

Voice view looks like this:

 <?xml version="1.0" encoding="UTF-8" ?> <response> <dial callerid="@ViewBag.CallerId"> @Html.Raw(ViewBag.NumberOfClient) </dial> </response> 

Then I try to make a test call:

enter image description here

but after 13 seconds the call ends automatically and in the error log I get:

 Notification SID NOe85ffe80dfc52e81f942a7414c9f7c9c Warning 12200 Schema validation warning Description Cannot find the declaration of element 'response'. 

But below in the Body section, I see a response element:

enter image description here

+2
source share
1 answer

Hi, Twilio evangelist developer is here.

Can you try changing your appearance to look like this?

 <?xml version="1.0" encoding="UTF-8" ?> <Response> <Dial callerId="@ViewBag.CallerId"> @Html.Raw(ViewBag.NumberOfClient) </Dial> </Response> 

Remember that XML is case sensitive, so the environment in your XML tags really matters. In addition, I would suggest using the Twilio.TwiML helper library. Thanks to this, you can get your XML code for you with the right body and avoid typos altogether.

Here's how you do it:

 var twiml = new TwilioResponse(); var dialAttributes = new {callerId = "48326304351"}; var dial = twiml.Dial("+15555555555", dialAttributes); return TwiML(dial); 
+2
source

All Articles