Reputation: 8234
How can I delete a call recording from twilio using the npm module ?
I am trying to use the request module like this:
request.del(recording_url, {
'auth': {
'user': accountSid,
'pass': authToken
}
}, function (err, done){
if(err){
console.log("error deleting from twilio", err)
} else {
console.log("removed from twilio", done);
}
});
I am getting the following info in the done
object:
body: '<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n<TwilioResponse><RestException><Code>20004</Code><Message>Method not allowed</Message><MoreInfo>https://www.twilio.com/docs/errors/20004</MoreInfo><Status>405</Status></RestException></TwilioResponse>'
Upvotes: 0
Views: 394
Reputation: 10366
Twilio evangelist here.
If you are using the Twilio node library you use this code to delete a recording resource:
var accountSid = 'AC3137d76457814a5eabf7de62f346d39a';
var authToken = "{{ auth_token }}";
var client = require('twilio')(accountSid, authToken);
client.recordings("RE557ce644e5ab84fa21cc21112e22c485").delete(function(err, data) {
if (err) {
console.log(err.status);
throw err.message;
} else {
console.log("Sid RE557ce644e5ab84fa21cc21112e22c485 deleted successfully.");
}
});
Check out the Recordings resource documentation for more info, specifically this example on deleting recordings.
Hope that helps.
Upvotes: 2