• pplication/x-www-form-urlencoded 请求格式调用


    public string Post(string Url, string jsonParas)
    {
    string res = string.Empty;
                try
                {
    byte[] byteArray = Encoding.Default.GetBytes(jsonParas);
    HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(new Uri(Url));
                    webReq.Method = "POST";
                    webReq.ContentType = "application/x-www-form-urlencoded";

                    webReq.ContentLength = byteArray.Length;
                    Stream newStream = webReq.GetRequestStream();
                    newStream.Write(byteArray, 0, byteArray.Length);
                    newStream.Close();
                    HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
                    StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
    res = sr.ReadToEnd();
                    sr.Close();
                    response.Close();
                    newStream.Close();
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
    return res;

    }

    //调用
    string para = "method=AZTSSchedule&projectNo=04118180&stationIds=12331232&productId=ASZXSS";
    Post("http://xxxx:8888/product/project", para);

  • 相关阅读:
    Application package 'AndroidManifest.xml' must have a minimum of 2 segments.
    让“是男人就下到100层”在Android平台上跑起来
    移植一个cocos2d-x游戏
    cocos2d-x宏定义
    职场之需求
    cocos2d-x for android配置 & 运行 Sample on Linux OS
    input函数出现的问题(Python)
    职场之英语
    职场之随手记
    应用商店后台MIS的一些思考
  • 原文地址:https://www.cnblogs.com/wdnrsjd/p/11022824.html
Copyright © 2020-2023  润新知