Using visual studio 2015, C#, constructed code to send sms using Ring Central SMS api,
Error details :- "The remote server returned an error: (401) Unauthorized."
Error while running the below code:
var JSONstr = new StringBuilder();
System.Net.WebRequest req = null;
System.Net.WebResponse rsp = null;
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Ssl3 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;
JSONstr.Append("{");
JSONstr.Append("\"to\"" + ":" + " [{" + "\"phoneNumber\"" + ":" +"\"+1234567890\"" + "}]" + ",");
JSONstr.Append("\"from\"" + ":" + " [{" + "\"phoneNumber\"" + ":" + "\"+12587419632\"" + "}]" + ",");
JSONstr.Append("\"text\"" + ":" + "\"Test SMS message\"");
JSONstr.Append("}");
string uri = "https://platform.ringcentral.com/restapi/v1.0/account/+19294682441/extension/101/sms";
if (uri != string.Empty && uri != null)
{
req = System.Net.WebRequest.Create(uri);
req.Method = "POST";
req.ContentType = "application/json";
System.IO.StreamWriter writer = new System.IO.StreamWriter(req.GetRequestStream());
writer.WriteLine(JSONstr.ToString());
writer.Close();
rsp = req.GetResponse();
Kindly help me..