使用Api json函数mvc解析值时遇到意外字符

时间:2018-11-01 10:38:21

标签: c# json asp.net-mvc

您好,我想在发送时使用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);

            }
        }

0 个答案:

没有答案