I am trying to Send sms via Twilio API but when i am using it via Jquery in my application its throwing
https://api.twilio.com/2010-04-01/Accounts/SID/Messages.json 401 (UNAUTHORIZED)
But when I am using the same SID and auth token via their website I am able to send SMS.
Please help how to make this work.
My code:
$(document).ready(function() {
$("#btnSubmit").click(function(){
$.ajax({
type: 'POST',
username: 'SID',
password: 'KEY',
url: 'https://api.twilio.com/2010-04-01/Accounts/SID/Messages.json',
xhrFields: {
withCredentials: true
},
data: {
"To" : "+918967385884",
"From" : "+12016902194",
"Body" : "Hello World"
},
success: function(data) {
console.log(data);
},
error: function(data) {
console.log(data);
}
});
});
});