1
votes

Hello guys I am trying to send sms from client side using twilio here is what I am trying

url = 'https://api.twilio.com/2010-04-01/Accounts/AC5b593d9bfeedd9e/Messages.json';
    axios.post(url,{
      "To" : "+9134324738",
      "From" : "+14698",
      "Body" : "Fgrgajshdkajsdhrom axios"
    },{headers: { Authorization: 'Basic sdfsdfsdf=',
    'Content-Type': 'application/x-www-form-url' }
  })

but I am getting 400 bad request response

here is what I am getting in response

{
    "code": 21603,
    "message": "A 'From' phone number is required.",
    "more_info": "https://www.twilio.com/docs/errors/21603",
    "status": 400
}

Please suggest some

1
try to enter valid phone numberStwosch
@Stwosch tried but getting same issue. I have just enter random number in questionSam
Try specifying a 10 digit phone number 1469867890 like following "From" : "+1469867890 "mike123
I had the same issue nothing i tried worked .I.Tyger

1 Answers

1
votes

Twilio developer evangelist here.

We do not recommend that you make requests to the Twilio API directly from your front end JavaScript application. To do so, you would need to store or retrieve your account SID and auth token in the client side somewhere. If you do this, then a malicious attacker could get access to your credentials and abuse your Twilio account.

Instead, we recommend you perform the API request on the server side and use your Angular app to make a request to your server to trigger the request.