zoukankan      html  css  js  c++  java
  • .net后台调用API接口

    string dd = model.Fatherid;
    string serviceAddress = "http://public.data.test.cn/api/PropertyData/GetFloorBuilding";
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceAddress);

    request.Method = "POST";
    request.ContentType = "application/json";
     string strContent = @"{ ""Fatherid"": " + "'" + dd + "'" + "}";//参数
    using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
    {
    dataStream.Write(strContent);//写入参数
    dataStream.Close();
    }
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    string encoding = response.ContentEncoding;
    if (encoding == null || encoding.Length < 1)
    {
    encoding = "UTF-8"; //默认编码
    }
    StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
    string retString = reader.ReadToEnd();
    //JObject jo = JObject.Parse(retString);
    //解析josn
    GetFloorBuildingResult jo1 = JsonConvert.DeserializeObject<GetFloorBuildingResult>(retString);
    return jo1;

    //GetFloorBuildingResult  返回结果

  • 相关阅读:
    logging模块
    configparser模块
    hashlib模块
    shutil模块
    json与pickle模块
    random模块
    OS模块
    如何不使用共享内存实现windows与虚拟机中进行文件的传输
    结构体的定义方式(仅定义)
    数据结构练习之寻找顺序表中的主要元素
  • 原文地址:https://www.cnblogs.com/tfeblog/p/10619301.html
Copyright © 2011-2022 走看看