Retrieving Values from a Json Array

0

Good afternoon,

In recent days I have developed a screen for sending messages, via sms, in C # mvc.

The api that I am consuming, returns through a webhook a json file, for my controller, I would like to know how to present this result in a textarea for the user.

Follow the submission part code:

[HttpPost]
public JsonResult Mensagem(string text, string destination, string cidade)
{  
    string apikey = "";
    string number = "55" + cidade + destination;
    string response = "";
    string msg = string.Empty;
    Uri uri = new Uri("http://panel.apiwha.com/send_message.php?apikey=" + System.Web.HttpUtility.UrlEncode(apikey) + "&number=" + 
    System.Web.HttpUtility.UrlEncode(number) + "&text=" + System.Web.HttpUtility.UrlEncode(text));

    HttpWebRequest requestFile = (HttpWebRequest)WebRequest.Create(uri);
    HttpWebResponse webResp = requestFile.GetResponse() as HttpWebResponse;
    if (requestFile.HaveResponse)
    {
        if (webResp.StatusCode == HttpStatusCode.OK || webResp.StatusCode == HttpStatusCode.Accepted)
        {
            StreamReader respReader = new StreamReader(webResp.GetResponseStream(), Encoding.GetEncoding("utf-8"));
            response = respReader.ReadToEnd();
            msg = "Mensagem Enviada";
            return Json(msg, JsonRequestBehavior.AllowGet);

        }
    }
    return Json(msg, JsonRequestBehavior.AllowGet);
}
    
asked by anonymous 12.12.2018 / 19:41

0 answers