Twilio the evangelist is here.
From the above code, it doesn't look like you are replacing the {AccountSid} token in the MessageApiString variable with the actual Sid account.
Also, it looks like you are adding phone number parameters to the URL as request values. Since this is a POST request, I believe that you need to include them as the request body, and not in the request queue, which means that you also need to set the ContentType property.
Here is an example:
var accountSid = "AC4*************0ab05bf"; var authToken = "0*************b"; var MessageApiString = string.Format("https://api.twilio.com/2010-04-01/Accounts/{0}/SMS/Messages.json", accountSid); var request = WebRequest.Create(MessageApiString); request.Method = "POST"; request.Credentials = new NetworkCredential(accountSid, authToken); request.ContentType = "application/x-www-form-urlencoded"; var body = "From=+442033*****3&To=+447*****732&Body=test"; var data = System.Text.ASCIIEncoding.Default.GetBytes(body); using (Stream s = request.GetRequestStream()) { s.Write(data, 0, data.Length); } var result = request.GetResponse();
Hope this helps.
Devin raader
source share