zoukankan      html  css  js  c++  java
  • .NET 后台请求API

    public static ResponseParam SendByHttpClienttoApi_LoginOn(string name, string password)
            {
                RequestParam para = new RequestParam()
                {
                    APPID = appid,
                    APPSecret = appsecrect,
                    MemberName = name,
                    Password = password,
                    IPAddress = WebHelper.GetClientIP()
                };
                using (var httpClient = new HttpClient())
                {
                    string jsonString = JsonConvert.SerializeObject(para);
                    byte[] bytes = Encoding.UTF8.GetBytes(jsonString);
                    using (StreamContent httpContent = new StreamContent(new MemoryStream(bytes)))
                    {
                        httpContent.Headers.ContentLength = bytes.Length;
                        httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
                        var result = httpClient.PostAsync("http://hisapi.customskb.com/api/Member/LoginNew", httpContent).Result.Content.ReadAsStringAsync().Result;
                        ResponseParam objectResult = JsonConvert.DeserializeObject<ResponseParam>(result);
                        return objectResult;
                    }
    
                }
            }
    

      

  • 相关阅读:
    jquery 初篇
    python作用域和js作用域的比较
    javascript作用域
    第三篇、dom操作续
    dom事件
    第二篇 dom内容操作之value
    第三篇、变量
    第二篇、常量
    Node.js
    测试用例
  • 原文地址:https://www.cnblogs.com/caolingyi/p/8548127.html
Copyright © 2011-2022 走看看