ASP.NET MVC API 接口验证的示例代码

2019-05-25 16:44:58于海丽

9、接口调用方法

    /// <summary>
    /// 测试留言接口调用
    /// </summary>
    /// <returns></returns>
    public ActionResult AddCustomerMessage()
    {
      string url = "http://192.168.1.88:808/api/CustomerMessage/Add?";
      WebClient webClient = new WebClient();
      NameValueCollection postValues = new NameValueCollection();

      postValues.Add("Message", "填写您的留言内容吧");
      postValues.Add("SendEmail", "youemail@qq.com");
      postValues.Add("SendTelephone", "021-60375335");
      postValues.Add("Code", "661137858");
      postValues.Add("AppKey", "wssavbcn");
      postValues.Add("AppSecret", "350e66b1e6564b0a817163erwwwwe8");
      postValues.Add("SystemFrom", "官网");

      byte[] responseArray = webClient.UploadValues(url, postValues);
      string response = Encoding.UTF8.GetString(responseArray);

      return Content(response);
    }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易采站长站。