Reputation: 397
I am building a phone-number verification app using Twilio. Following this tutorial closely. However, I am unable to generate a valid XML like how this specific page says. How can I fix this?
My main problem is that I am unable to get Twilio to read the TwiML document which I set up in twilio-quickstart.rb. I have run ruby twilio-quickstart.rb and exposed my port using ngrok. On the browser, I can see the words in TwiML tags but in the call, keep getting Application Error. Twilio logs indicate HTTP retrieval failure with this message.
An attempt to retrieve content from http://adfsfsdf.ngrok.io/hello-monkey returned the HTTP status code 404.
Suspecting an error with the way the XML document is generate (I may be wrong) In the browser...Instead of getting this...
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Hello Monkey</Say>
</Response>
I am getting this...
Press 1 to verify your number
Whereas one of the example urls given shows the xml page clearly.
Just to be sure - I have set up my ngrok properly.
How can I generate the XML document properly? Or, how I can overcome the HTTP retrieval error that Twilio logs are showing?
Upvotes: 0
Views: 57
Reputation: 73057
Twilio developer evangelist here.
There are a few things that could be going on here, so I might not be right to start with, but we can work to get this sorted for you.
The error you're getting from Twilio is a 404, meaning that Twilio can't find the URL it's looking for. If you can hit your own endpoint and get a response then there is probably something wrong between you and Twilio.
I'm not sure how you've set ngrok up, but that may be the issue. Everytime you restart ngrok you get a new subdomain, so you may need to update your URL on your Twilio number.
In the case of not seeing the XML in the browser, it's because the quickstart doesn't set the right content type. You can fix that, in Sinatra, by setting the content type, and you'd do so like this:
get '/hello-monkey' do
content_type "text/xml"
Twilio::TwiML::Response.new do |r|
r.Say 'Hello Monkey'
end.text
end
Let me know if this helps at all.
Upvotes: 1