您好,我想在发送时使用Api发送OTP在此行显示此错误:
var jsonObject = JObject.Parse(result);
任何人都可以告诉我这行的问题是什么
错误:
Newtonsoft.Json.JsonReaderException:'解析值时遇到意外字符:<。路径”,第0行,位置0。'
public JsonResult SOTP()
{
int otpValue = new Random().Next(100000, 999999);
var status = "";
try
{
string recipient = ConfigurationManager.AppSettings["RecipientNumber"].ToString();
string APIKey = ConfigurationManager.AppSettings["APIKey"].ToString();
string message = "Your OTP Number is " + otpValue + " ( Sent By : Technotips-Ashish )";
String encodedMessage = HttpUtility.UrlEncode(message);
using (var webClient = new WebClient())
{
byte[] response = webClient.UploadValues("https://control.txtlocal.co.uk/send/", new NameValueCollection(){
{"apikey" , APIKey},
{"numbers" , recipient},
{"message" , encodedMessage},
{"sender" , "TXTLCL"}});
string result = System.Text.Encoding.UTF8.GetString(response);
var jsonObject = JObject.Parse(result);
status = jsonObject["status"].ToString();
Session["CurrentOTP"] = otpValue;
}
return Json(status, JsonRequestBehavior.AllowGet);
}
catch (Exception e)
{
throw (e);
}
}