zoukankan      html  css  js  c++  java
  • 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);

  • 相关阅读:
    Centos7永久修改hostname
    centos静态绑定IP地址
    Salesforce 报表开发
    Salesforce 测试类的实践
    Salesforce Aura开发 Component组件开发实践
    Salesforce Aura 开发 Hello World开发实践
    PHP设计模式之工厂模式
    PHP设计模式之单例模式
    PHP截取带有汉字的字符串,将汉字按两个字节计算
    window下安装Apache+PHP
  • 原文地址:https://www.cnblogs.com/wdnrsjd/p/11022824.html
Copyright © 2011-2022 走看看