I'm trying to make a phone call using twilio programmable voice with TwiML. Not sure if I'm doing something completely wrong, but I created an express route to output TwiML
router.get('/data', function(req, res) {
var testXML = builder.create('Response')
.ele('Say')
.att('voice', 'alice')
.txt('You ordered a hamburger')
.ele('Say')
.txt('Now this order is complete')
res.type('text/xml');
res.set('Content-Type', 'text/xml');
res.send(testXML.toString());
});
This outputs XML as seen below:
My code to make the phone call is as follows:
client.calls
.create({
url: 'http://XXXXX.com/api/request',
to: '+1XXXXXXXXXX',
from: '+1XXXXXXXXXX',
})
.then(call => console.log(call.sid))
.done();
But twilio keeps outputting Error - 11200 HTTP retrieval failure. Any ideas?
I noticed in the REST API call, you are passing a URL with the path:
But your Express Route is /data. Also, Twilio uses POST by default, unless you indicate GET in the REST API call.